class Amber::Mailer::Configuration

Overview

Configuration for the Amber mailer system.

Manages adapter selection and SMTP connection settings. Uses a singleton pattern to provide a single global configuration instance.

Configuration

Amber::Mailer::Configuration.configure do |config|
  config.adapter = :smtp
  config.smtp_host = "smtp.example.com"
  config.smtp_port = 587
  config.smtp_username = "[email protected]"
  config.smtp_password = "secret"
  config.use_tls = true
  config.default_from = "[email protected]"
  config.helo_domain = "example.com"
end

Adapters

Two built-in adapters are available:

Defined in:

amber/mailer/configuration.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.instance : Configuration #

Returns the singleton configuration instance.

Creates a new instance with default values if one does not exist.


[View source]

Class Method Detail

def self.configure(&) : Nil #

Yields the singleton configuration instance for modification.

Amber::Mailer::Configuration.configure do |config|
  config.adapter = :smtp
end

[View source]
def self.reset : Nil #

Resets the configuration to default values.

Useful in tests to ensure a clean configuration state.


[View source]

Instance Method Detail

def adapter : Symbol #

[View source]
def adapter=(adapter : Symbol) #

[View source]
def build_adapter : DeliveryAdapter #

Builds a delivery adapter instance based on the current configuration.

Returns a MemoryAdapter for :memory or an SMTPAdapter configured with the current SMTP settings for :smtp.

Raises ArgumentError if the adapter symbol is not recognized.


[View source]
def default_from : String #

[View source]
def default_from=(default_from : String) #

[View source]
def helo_domain : String #

[View source]
def helo_domain=(helo_domain : String) #

[View source]
def smtp_host : String #

[View source]
def smtp_host=(smtp_host : String) #

[View source]
def smtp_password : String | Nil #

[View source]
def smtp_password=(smtp_password : String | Nil) #

[View source]
def smtp_port : Int32 #

[View source]
def smtp_port=(smtp_port : Int32) #

[View source]
def smtp_username : String | Nil #

[View source]
def smtp_username=(smtp_username : String | Nil) #

[View source]
def use_tls : Bool #

[View source]
def use_tls=(use_tls : Bool) #

[View source]