Kantoor. MailSource behaviour
(Kantoor v1.0.0)
What Kantoor needs from the system that stores and transports its mail,
independent of that system's URLs. Kantoor.Karta.Client (and its
implementation Kantoor.Karta.ReqClient) is the only implementation.
Identifiers are opaque strings the source chose: a message id names a stored
message body (Kantoor keeps it in messages.karta_message_id), a delivery id
names one recipient's copy of it (messages.karta_delivery_id, unique).
This behaviour covers the calls Kantoor makes. It does not cover how new mail
reaches Kantoor: Karta pushes it (KantoorWeb.KartaInboundController,
Kantoor.Karta.InboundPayload, Kantoor.Ingest). A source that has to be
polled needs its own ingest path. See docs/mail-sources.md.
Summary
Types
A domain's route in the source: the domain's name and the endpoint it points at.
Callbacks
Makes the source deliver a domain's mail to this Kantoor (push sources only).
Forgets this Kantoor's copy of one delivery. Idempotent: an unknown delivery is
:ok. Option :domain names the mail domain, for a source with one
organisation per domain.
The message's raw RFC 822 bytes; option :range is {first, last} (inclusive byte offsets).
Reachability and version of the source.
The mail domains this Kantoor may serve.
One message's metadata.
Sends a complete message. Options: :mail_from, :rcpt_to (list), :retention
("keep" or a number of days), :auto_reply (send with the null envelope sender,
for an automatic reply; a source that cannot falls back to :mail_from). Returns the source's answer; an "id" or
"message_id" key, when present, names the stored sent copy.
Switches a domain's delivery to this Kantoor on or off (push sources only).
Types
@type error() :: :not_configured | {:http, pos_integer()} | {:refused, pos_integer(), String.t(), String.t() | nil} | {:transport, Exception.t()} | term()
A domain's route in the source: the domain's name and the endpoint it points at.
Callbacks
@callback attach_domain(domain :: map(), opts :: keyword()) :: {:ok, %{ :route_id => String.t() | nil, :endpoint_id => String.t() | nil, optional(:secret) => String.t() | nil }} | {:error, error()}
Makes the source deliver a domain's mail to this Kantoor (push sources only).
Forgets this Kantoor's copy of one delivery. Idempotent: an unknown delivery is
:ok. Option :domain names the mail domain, for a source with one
organisation per domain.
@callback fetch_raw(message_id :: String.t(), opts :: keyword()) :: {:ok, binary()} | {:error, error()}
The message's raw RFC 822 bytes; option :range is {first, last} (inclusive byte offsets).
Reachability and version of the source.
The mail domains this Kantoor may serve.
One message's metadata.
Sends a complete message. Options: :mail_from, :rcpt_to (list), :retention
("keep" or a number of days), :auto_reply (send with the null envelope sender,
for an automatic reply; a source that cannot falls back to :mail_from). Returns the source's answer; an "id" or
"message_id" key, when present, names the stored sent copy.
Switches a domain's delivery to this Kantoor on or off (push sources only).