Karta. SMTP. Session
(Karta v1.0.0)
The SMTP server protocol as a pure state machine.
handle_line/2, data_received/2 and bdat_received/4 return
{session, actions}, where actions are:
{:reply, Reply.t()}- send this reply:start_tls- after flushing replies, discard buffered input and do the TLS handshake, then calltls_started/1{:start_data, max}- read a DATA section withDataReader, then calldata_received/2{:start_bdat, size, last?}- read exactlysizebytes, then callbdat_received/4{:discard, size}- read exactlysizebytes and drop them (a refused BDAT chunk):close- flush and close
Summary
Functions
config: hostname, listener (:mx | :submission | :submissions),
tls_available, auth (:disabled | :tls_only), limits, and the opt-in
extensions dsn and requiretls. Both default to off. Advertising DSN
obliges Karta to honour the requests: it does for mail submitted to be
delivered (the submission listeners enable it, and write the delivery
status notifications), and not yet for mail it receives and passes on
(the mx listener does not). Advertising REQUIRETLS (after STARTTLS only) obliges it to
deliver such messages only over verified TLS to servers that support
REQUIRETLS (RFC 8689), which outbound delivery does: the submission
listeners may enable it, the mx listener not before mail it receives can
be passed on.
scram_nonce (a function returning a nonce; default
Karta.SASL.SCRAM.nonce/0) exists for test vectors.
Records what the TLS handshake negotiated, %{version: "TLSv1.3", cipher: "TLS_AES_256_GCM_SHA384"}, for the Received: field. The connection
calls it once the handshake is done.
Types
@type action() :: {:reply, Karta.SMTP.Reply.t()} | :start_tls | {:start_data, pos_integer()} | {:start_bdat, non_neg_integer(), boolean()} | {:discard, non_neg_integer()} | :close
Functions
config: hostname, listener (:mx | :submission | :submissions),
tls_available, auth (:disabled | :tls_only), limits, and the opt-in
extensions dsn and requiretls. Both default to off. Advertising DSN
obliges Karta to honour the requests: it does for mail submitted to be
delivered (the submission listeners enable it, and write the delivery
status notifications), and not yet for mail it receives and passes on
(the mx listener does not). Advertising REQUIRETLS (after STARTTLS only) obliges it to
deliver such messages only over verified TLS to servers that support
REQUIRETLS (RFC 8689), which outbound delivery does: the submission
listeners may enable it, the mx listener not before mail it receives can
be passed on.
scram_nonce (a function returning a nonce; default
Karta.SASL.SCRAM.nonce/0) exists for test vectors.
Records what the TLS handshake negotiated, %{version: "TLSv1.3", cipher: "TLS_AES_256_GCM_SHA384"}, for the Received: field. The connection
calls it once the handshake is done.