Sovite.Core.Recipients (sovite v0.2.0)

Copy Markdown View Source

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, unless domains.local_recipients is set: then only those (and postmaster@, abuse@).
  • :aliased - only aliases, so an address that reaches check/2 unexpanded is unknown.
  • :hosted - mailboxes (sovitectl mailbox), or @domain for all.
  • :relay and :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

error()

@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

bcc(routing, sender, recipients)

@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.

check(routing, address)

@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.

expand(routing, address)

@spec expand(Sovite.Core.Routing.t(), String.t()) ::
  {:ok, [String.t(), ...]} | error()

Expands address. Returns the final addresses, without duplicates.