Karta.Outbound.Source (Karta v1.0.0)

The bytes of a message as they are handed to Karta.SMTP.Client after DATA: a message held in memory, or a stored message read again as it is sent.

A stored message is sent as prefix (the DKIM-Signature fields, or nothing when it is sent unsigned), then its body from skip on — the header block that the signature replaces, or that was already sent. Each target of one envelope reads the stored message again, which is what a message of any size costs: one chunk at a time, never the message.

Summary

Functions

Hands the message's bytes to emit, in order, in pieces of any size: {:ok, acc} to go on, {:error, reason} to stop. A stored message is read again from its body for each call (Karta.Storage.stream/4), so a failed first target does not leave the next one without a message.

A message read from the blob store as it is sent.

The octets of the message as sent, which SIZE and the server's limit are checked against.

Types

t()

@type t() ::
  binary()
  | %Karta.Outbound.Source{
      message: Karta.Messages.Message.t(),
      opts: keyword(),
      prefix: iodata(),
      size: non_neg_integer(),
      skip: non_neg_integer()
    }

Functions

fold(message, acc, emit)

@spec fold(t(), acc, (binary(), acc -> {:ok, acc} | {:error, term()})) ::
  {:ok, acc} | {:error, term()}
when acc: var

Hands the message's bytes to emit, in order, in pieces of any size: {:ok, acc} to go on, {:error, reason} to stop. A stored message is read again from its body for each call (Karta.Storage.stream/4), so a failed first target does not leave the next one without a message.

new(body, prefix, skip, message, opts)

A message read from the blob store as it is sent.

size(message)

@spec size(t()) :: non_neg_integer()

The octets of the message as sent, which SIZE and the server's limit are checked against.