Recipient expansion and validation.
Expansion
expand/2 turns a recipient into the addresses the mail is queued
for, using the aliases in the database (sovitectl alias). Keys tried,
in order (see Sovite.Core.Routing.lookup/4): user+ext@domain,
user@domain, the bare local part for local domains, then @domain.
An extension the alias did not match is kept: with an alias for
alice@example.com, mail for alice+lists@example.com goes to each
destination with +lists added.
Destinations are expanded again, up to 100 levels and 1000 addresses.
An address that comes back to itself (team -> team, alice) is kept,
not expanded again.
postmaster@ and abuse@ an aliased or hosted domain without an alias
or mailbox go to postmaster@ the server's host name, so they always
reach someone (RFC 5321 §4.5.1, RFC 2142).
Validation
check/2 decides whether a single address (after expansion) is known,
by its domain class (Sovite.Core.Routing.class/2):
:local- any address, unlessdomains.local_recipientsis set: then only those (andpostmaster@,abuse@).:aliased- only aliases, so an address that reachescheck/2unexpanded is unknown.:hosted- mailboxes (sovitectl mailbox), or@domainfor all.:relayand:remote- any address.
It also rejects users who moved (sovitectl moved) with 5.1.6 and
their new location.
BCC
bcc/3 adds routing.always_bcc, and the copies the BCC rules
(sovitectl bcc) give for the sender and each recipient, by address,
then @domain.
Summary
Types
Why expansion failed: a table could not be read, or the aliases are broken. The client should try again later. The text is for the log.
Functions
The BCC addresses for a message, see the module documentation.
Checks a single address. Returns its class, a rejection (550 with
the status and text), or {:error, text} when a table cannot be read.
Expands address. Returns the final addresses, without duplicates.
Types
@type error() :: {:error, :temporary, String.t()}
Why expansion failed: a table could not be read, or the aliases are broken. The client should try again later. The text is for the log.
Functions
@spec bcc(Sovite.Core.Routing.t(), String.t(), [String.t()]) :: {:ok, [String.t()]} | {:error, String.t()}
The BCC addresses for a message, see the module documentation.
@spec check(Sovite.Core.Routing.t(), String.t()) :: {:ok, Sovite.Core.Routing.class()} | {:reject, String.t(), String.t()} | {:error, String.t()}
Checks a single address. Returns its class, a rejection (550 with
the status and text), or {:error, text} when a table cannot be read.
@spec expand(Sovite.Core.Routing.t(), String.t()) :: {:ok, [String.t(), ...]} | error()
Expands address. Returns the final addresses, without duplicates.