Karta.Messages.Intake (Karta v1.0.0)

Stores a message received over SMTP, for a policy's accept_message/2.

accept/3 returns {:ok, queue_id} only after the body is in the blob store and the database says the message is accepted (Karta.Messages); the session sends 250 only then. Every failure on the way returns a temporary 451 4.3.0, so the client keeps the message and tries again, and whatever was written is discarded at once or, if that fails too, by the retention sweep.

The stored body is Karta's Received: field (Karta.Mail.ReceivedHeader) followed by the message exactly as received. The header block is checked first (Karta.Mail.Headers limits); a message whose header block is too large is refused permanently.

An outgoing message is accepted together with its delivery jobs (Karta.Outbound.accept/2): it is never acknowledged without them.

Options:

  • :server (required) - the Karta.Servers.Server (or its id) the message belongs to;
  • :direction - :incoming or :outgoing; by default :incoming on an mx listener and :outgoing on the submission listeners;
  • :blob_store - overrides the configured blob store (see Karta.Storage);
  • :check - a function given the parsed header fields before anything is stored, returning :ok or {:reject, reply} (the submission policy checks the author with it);
  • :suppressed - recipients of an outgoing message that are not to be delivered to (see Karta.Outbound.accept/3);
  • :accept - for an incoming message, a function given the message id that accepts it, returning :ok or {:error, reason} (default Karta.Messages.mark_accepted/1; the mx listener's policy accepts it with its deliveries, Karta.Inbound.accept/2);
  • :prepend - header fields (iodata) stored before Karta's Received: (the mx listener's Authentication-Results:);
  • :drop - a function given each header field, true for fields that are not stored (an Authentication-Results: field that claims to be Karta's); the rest of the message is stored as received;
  • :auth_results - the authentication results kept with the message (Karta.Auth.to_map/1);
  • :relay_credential_id - the IP range credential that let an outgoing message in (Karta.SMTP.Relay); absent for mail submitted with AUTH.
  • :scan - what the spam and virus scanners said, kept with the message (Karta.Scan.stored/2).

Summary

Functions

accept(session, spool_file, opts)

@spec accept(Karta.SMTP.Session.t(), Karta.SMTP.SpoolFile.t(), keyword()) ::
  {:ok, String.t()} | {:reject, Karta.SMTP.Reply.t()}