Karta. SMTP. Policy. Inbound
(Karta v1.0.0)
The policy of the mx listener: mail for the addresses that servers route
(Karta.Inbound), decided while the sender is still connected, so that
Karta never has to bounce what it accepted.
RCPT is answered from the routes in memory (
Karta.Inbound.Directory), never from the database:550 5.1.2for a domain Karta does not receive mail for (no open relay),550 5.1.1for an address without a route or with a route that rejects, and451 4.3.2while the node has not loaded the routes yet (the sender tries again later). A message goes to one mail server: a recipient routed to another server than the first recipient's gets452 4.5.3, and the sender sends it in another transaction.Bounces of forwarded mail come back to the SRS address the forward was sent from (
Karta.Inbound.SRS): an SRS address of Karta's SRS domain is accepted when it is valid (made by Karta, at most 21 days ago) and the message is a bounce (the null sender); otherwise it is refused (550 5.1.1, or550 5.7.1for a sender that is not null), so nobody can relay through it. Such a bounce is in a message of its own (452 4.5.3beside routed recipients), and it is accepted and dropped: passing a bounce on would need the forward's original sender to have been authenticated, which Karta does not record for that purpose yet.Bounces of sent mail come back to the VERP return path (
Karta.Outbound.ReturnPath,KARTA_RETURN_PATH_DOMAIN): a return path of that domain is accepted when the tag is one Karta made and is no older thanKARTA_BOUNCE_MAX_AGE_DAYS(default 30), and the message is a bounce (the null sender);550 5.1.1for a tag Karta did not make and550 5.2.1for an expired one,550 5.7.1for a sender that is not null. Such a message is one recipient's own (452 4.5.3otherwise); at the end of data it is read as a delivery status notification (RFC 3464, or the bounce's text when it is not one), recorded against the recipient, and refused with550 5.1.1when its recipient or message is gone. Nothing is stored and no notification is sent about it (Karta.Bounces).End of data: the loop guard refuses, with
554 5.4.6, a message withmax_hopsor moreReceived:fields (default 50; RFC 5321 §6.3), and a message that carries aDelivered-To:field naming one of its recipients: it was delivered to that address before, and has come back. When a recipient's route changed since RCPT, the answer is451 4.3.0and the sender tries again.Authentication (
Karta.Auth): SPF, DKIM, DMARC and ARC are checked before the answer to the data (at most 20 seconds). A message that fails DMARC for an author domain whose owner asks for rejection (p=reject, not in test mode), without a trusted ARC sealer vouching for it, is refused with550 5.7.1when every recipient's route hasdmarc_reject(the default), and so is one that names more than five author domains; nothing else is refused for its authentication, and a check that could not finish (temperror) never refuses. Otherwise the message is stored with anAuthentication-Results:field on top under Karta's authserv-id (config :karta, Karta.Auth, authserv_id:, default the listener's host name), every such field that already claimed that id removed, and the results kept with the message (auth_results). It is accepted with a delivery per recipient (Karta.Inbound.accept/2).Scanning (
Karta.Scan): before anything is stored, rspamd and ClamAV look at the message, within a time budget. A virus refuses it (554 5.7.1); spam a recipient's route rejects refuses it (550 5.7.1); spam a route holds is stored with that delivery held; a scanner that cannot answer refuses it (451 4.7.1) when any recipient's route is fail-closed, and is marked otherwise. The scan's fields go on top of the stored message and its results are kept with it (messages.scan). Nothing is scanned when no scanner is configured.Relayed mail (
KARTA_SMTP_MX_IP_RELAY=true, policy optionip_relay: true): a client whose address is in one of a server's ranges (Karta.SMTP.Relay) is identified at its firstMAIL FROMand then sends as on the submission listeners: any recipient, from the verified domains of that server's organisation (Karta.SMTP.Policy.Outgoing). Without the option no range is looked up and every client is an ordinary mx client. When the option is on and the database fails,MAILis answered451 4.3.0(the sender retries) rather than risk a relay decision made without it.
Options (policy_opts): :domains_cache (the routes' cache, default
Karta.SMTP.Policy.Closed.domains_cache/0), :max_hops, :blob_store,
:auth (options for Karta.Auth.verify/3), :ip_relay (accept relayed
mail from address ranges; default false), :scan (options for
Karta.Scan.run/2).