Karta.Outbound.DSN (Karta v1.0.0)

Delivery status notifications (RFC 3464): the message Karta sends back to the submitter of a message about some of its recipients.

The DSN is a multipart/report; report-type=delivery-status with three parts: a short text for people, the machine-readable message/delivery-status (per-message fields, then one group of fields per recipient), and the original message's header (text/rfc822-headers) or, when the submitter asked with RET=FULL and the message is at most 1 MiB, the whole message (message/rfc822).

When an address or the original message is internationalised, the RFC 6533 forms are used instead: message/global-delivery-status with utf-8 addresses, and message/global-headers or message/global; the DSN itself then needs SMTPUTF8 (build/1 says so).

Karta does not pass DSN requests on to the next server, so a delivery reported as a success has the action relayed (RFC 3461 §6.2.6.2): the message reached the recipient's server, which may or may not report further.

Summary

Functions

Builds a DSN. report has

Types

recipient()

@type recipient() :: %{
  address: String.t(),
  orcpt: String.t() | nil,
  action: :failed | :relayed,
  status: String.t(),
  remote_mta: String.t() | nil,
  diagnostic: String.t() | nil,
  explanation: String.t() | nil
}

Functions

build(report)

@spec build(map()) :: %{data: binary(), smtputf8: boolean()}

Builds a DSN. report has:

  • :reporting_mta - Karta's host name;
  • :to - the original envelope sender, who receives the DSN;
  • :message_id - the DSN's own Message-ID (without angle brackets);
  • :date - when the DSN is made; :arrival - when the original arrived;
  • :original - the original message as stored; :ret - :full, :hdrs or nil; :envid - the ENVID parameter or nil; :smtputf8 - the original was submitted with SMTPUTF8;
  • :recipients - a list of recipient/0: diagnostic is the server's reply ("550 5.1.1 No such user") when one was given, explanation Karta's own reason when no server decided.

Returns %{data: message, smtputf8: boolean}.