Karta. Complaints. ARF
(Karta v1.0.0)
Reading feedback reports (RFC 5965): the abuse reports that providers send a sender when a recipient marks its mail as spam.
A feedback report is a multipart/report whose report-type is
feedback-report and which carries a message/feedback-report part
(the machine-readable fields) and, when the reporter includes it, the
message complained about as message/rfc822. parse/1 reads the part
into a Karta.Complaints.ARF.Report; the quoted message is read for its
Message-ID only, and only to record it.
A report is matched to a message by the VERP return path it arrived at
(Karta.Outbound.ReturnPath), never by anything the report says: its
fields and the quoted message are written by the reporter. See
Karta.Complaints.Report.
Parsing is bounded as in Karta.Bounces.DSN: the MIME tree at most 10
deep and 50 parts, a feedback-report part at most 65,536 bytes and 100
fields, each value at most 255 characters (Karta.Mail.Text), and the
quoted message's header block at most 65,536 bytes. A part too large for
its purpose is refused rather than half-read.
Summary
Functions
The fields of the message/feedback-report part of a parsed message,
as Karta.Mail.Headers reads them, within the bounds above. For
readers of other feedback reports (DMARC failure reports) that need
fields parse/1 does not keep. {:error, :not_a_feedback_report},
{:error, :too_large}, {:error, :too_many_fields} or
{:error, :line_too_long}.
True when a parsed message is a feedback report: its report-type says
so, or it carries a message/feedback-report part. Used to tell a
feedback report from a bounce; parse/1 needs the part itself.
The Message-ID of the message quoted in a feedback report, for the
record: never for matching. nil when nothing is quoted.
Reads a feedback report. {:ok, report}, or {:error, reason}:
:not_a_feedback_report (no message/feedback-report part),
:too_large, :too_many_fields, :line_too_long, or what
Karta.Mail.Message.parse/2 says about an unreadable message.
Functions
@spec feedback_fields(Karta.Mail.Part.t()) :: {:ok, [Karta.Mail.Header.t()]} | {:error, atom()}
The fields of the message/feedback-report part of a parsed message,
as Karta.Mail.Headers reads them, within the bounds above. For
readers of other feedback reports (DMARC failure reports) that need
fields parse/1 does not keep. {:error, :not_a_feedback_report},
{:error, :too_large}, {:error, :too_many_fields} or
{:error, :line_too_long}.
@spec feedback_report?(Karta.Mail.Part.t()) :: boolean()
True when a parsed message is a feedback report: its report-type says
so, or it carries a message/feedback-report part. Used to tell a
feedback report from a bounce; parse/1 needs the part itself.
@spec original_message_id(Karta.Mail.Part.t()) :: String.t() | nil
The Message-ID of the message quoted in a feedback report, for the
record: never for matching. nil when nothing is quoted.
@spec parse(binary()) :: {:ok, Karta.Complaints.ARF.Report.t()} | {:error, :not_a_feedback_report | :too_large | :too_many_fields | atom()}
Reads a feedback report. {:ok, report}, or {:error, reason}:
:not_a_feedback_report (no message/feedback-report part),
:too_large, :too_many_fields, :line_too_long, or what
Karta.Mail.Message.parse/2 says about an unreadable message.