Karta.SMTP.Policy.Submission (Karta v1.0.0)

The policy of the submission listeners (ports 587 and 465): clients log in with an SMTP credential of a mail server (Karta.Credentials) and send mail from the verified domains of that server's organisation (Karta.Domains), or connect from an address in one of the server's ranges and send without AUTH (Karta.SMTP.Relay).

  • AUTH PLAIN, LOGIN and SCRAM-SHA-256. The session's identity is %{credential_id: id, server_id: id, organisation_id: id}.
  • A range is matched against the connection's peer address at the first MAIL FROM of an unauthenticated connection, and gives an identity with via: :ip; the rules of both are Karta.SMTP.Policy.Outgoing.
  • MAIL: the credential or range must still be active and its server not suspended; the credential's rate limit (Karta.Credentials.rate_limit/1 messages a minute, counted in the database by Karta.Limits) is checked; a range with tls_required needs TLS; the envelope sender must be the null path or an address at a verified domain.
  • RCPT: any recipient.
  • End of data: every mailbox in From and Sender must be at a verified domain (Karta.Domains.check_from/2, on parsed addresses); the message is then stored and queued for delivery (Karta.Messages.Intake). Recipients on the server's suppression list (Karta.Suppressions) are recorded but not delivered to.

A connection that has neither authenticated nor matched a range gets 530 5.7.0 Authentication required at MAIL, and no range is looked up when the client authenticated.

Unlike the mx listener, which must answer from memory, submission reads the database: a message cannot be accepted without it anyway, and a revoked credential, range or withdrawn domain takes effect at once. When the database fails the answers are temporary (454 4.7.0 at AUTH, 451 4.3.0 otherwise), so clients try again.

Option (policy_opts): :blob_store (see Karta.Storage).