Karta.Outbound.Body (Karta v1.0.0)

A stored outgoing message read once, in chunks, for delivery: the facts a delivery needs about it, and the body hashes DKIM signs, without holding the message.

What one pass gives:

  • size — the octets of the message, for the SIZE parameter of MAIL FROM and the local check against the receiving server's limit;
  • header and skip — the header block as stored and its length, which is what a signature replaces;
  • fields — the header fields, parsed (Karta.Mail.Headers);
  • eight_bit — whether any octet of the message is not ASCII, which asks for BODY=8BITMIME;
  • header_ascii — whether the header block is ASCII, which decides SMTPUTF8 together with the envelope;
  • bare_line_ending — whether a CR or LF stands alone: such a message is bounced, never sent (Karta.SMTP.Client.Stuff);
  • tls_required_no — RFC 8689 §3: exactly one TLS-Required field, with the value No;
  • body_hash — for each canonicalisation asked for, the SHA-256 of the canonical body (Karta.Auth.DKIM.BodyHash), which a signature needs in front of the message it signs.

A message whose header block cannot be parsed (over a megabyte, a line over 8192 octets, or a line that is neither a field nor a continuation with no empty line before it) has header and fields nil: it is sent as it is and unsigned, as Karta.Outbound.Signing did before.

Summary

Functions

The same facts for a message held in memory, with the same options as scan/2.

Reads the message's stored body once. Options: :blob_store (as Karta.Storage), and :hash — the body canonicalisations whose hashes the caller needs ([:relaxed], [:simple, :relaxed], or none).

Types

t()

@type t() :: %Karta.Outbound.Body{
  bare_line_ending: boolean(),
  body_hash: %{required(atom()) => binary()} | nil,
  eight_bit: boolean(),
  fields: [Karta.Mail.Header.t()] | nil,
  header: binary() | nil,
  header_ascii: boolean(),
  size: non_neg_integer(),
  skip: non_neg_integer(),
  tls_required_no: boolean()
}

Functions

of(raw, opts \\ [])

@spec of(binary(), keyword()) :: t()

The same facts for a message held in memory, with the same options as scan/2.

scan(message, opts \\ [])

@spec scan(Karta.Messages.Message.t(), keyword()) :: {:ok, t()} | {:error, term()}

Reads the message's stored body once. Options: :blob_store (as Karta.Storage), and :hash — the body canonicalisations whose hashes the caller needs ([:relaxed], [:simple, :relaxed], or none).