class

Alumna::SMTP

Inherits Alumna::Mailer < Reference < Object

SMTP mailer. One method: send. This is not a Redis-style holder.

Each send opens one new connection, runs one dialog, and closes it. There is no shared connection state, so concurrent sends are safe.

Success returns nil. A server refusal, a network error, a TLS error, or a timeout returns MailError. Config mistakes raise ArgumentError.

Do not log the password. MailError text has the username and the password removed.

Constants

DEFAULT_CONNECT_TIMEOUT = 10.seconds
DEFAULT_READ_TIMEOUT = 30.seconds
DEFAULT_WRITE_TIMEOUT = 30.seconds

Constructors

from_env(*, helo_name : String = System.hostname, tls_context : OpenSSL::SSL::Context::Client = OpenSSL::SSL::Context::Client.new) : self

Reads SMTP_HOST, and the optional SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, and SMTP_TLS (starttls, implicit, or none; not case sensitive). A variable that is set must not be empty.

Source
new(*, host : String, port : Int32 | Nil = nil, tls : TLS = :starttls, username : String | Nil = nil, password : String | Nil = nil, helo_name : String = System.hostname, tls_context : OpenSSL::SSL::Context::Client = OpenSSL::SSL::Context::Client.new, connect_timeout : Time::Span = DEFAULT_CONNECT_TIMEOUT, read_timeout : Time::Span = DEFAULT_READ_TIMEOUT, write_timeout : Time::Span = DEFAULT_WRITE_TIMEOUT)

port nil means the default port of the mode (587, 465, or 25). tls_context checks the server certificate. The default uses the system CAs. Pass another context for a private CA or a client certificate.

Source

Instance methods

helo_name
Source
host
Source
port
Source
send(mail : Mail) : Nil | MailError
Source

Nested types