Behaviour + facade for the Accrue transactional email pipeline.
Semantic API
Callers invoke Accrue.Mailer.deliver/2 with an email type atom and a
plain assigns map. The configured adapter (Accrue.Mailer.Default by
default) is responsible for turning the type + assigns into a rendered email
and delivering it. Callers never construct a %Swoosh.Email{} directly —
that is the adapter's job, keeping call sites decoupled from the email
rendering pipeline.
Per-type kill switch
Set config :accrue, :emails, [<type>: false] to disable a specific
transactional email type. When a type is disabled, deliver/2 returns
{:ok, :skipped} immediately without enqueueing a job or rendering
anything. The :emails config schema is defined by Accrue.Config.
Telemetry
Every deliver/2 call emits [:accrue, :mailer, :deliver, :start | :stop | :exception] with %{email_type: atom, customer_id: binary | nil} metadata.
Raw assigns and rendered email bodies are NEVER placed in metadata — they
may carry PII.
Summary
Functions
Delivers a transactional email by type + assigns. Delegates to the
configured adapter (default Accrue.Mailer.Default).
Returns true if the given email type is not disabled via the
:emails kill switch.
Types
Callbacks
@callback deliver(email_type(), assigns()) :: {:ok, term()} | {:error, term()}
Functions
@spec deliver(email_type(), assigns()) :: {:ok, term()} | {:error, term()}
Delivers a transactional email by type + assigns. Delegates to the
configured adapter (default Accrue.Mailer.Default).
Returns {:ok, :skipped} when the email type is disabled via the
:emails kill switch. Otherwise returns whatever the adapter returns
(typically {:ok, %Oban.Job{}} for async enqueue).
@spec enabled?(email_type()) :: boolean()
Returns true if the given email type is not disabled via the
:emails kill switch.