LemonChannels.Adapters.Email.MessageId (lemon_channels v0.1.0)

View Source

RFC 2822 message identifiers: parsing, listing and rendering.

Message ids arrive in every shape a mail provider can invent — bracketed (<abc@host>), bare, whitespace- or comma-separated in a References header, already split into a list, or as a {name, value} header tuple. The adapter, the thread store and outbound delivery all have to agree on what an id is, so the parsing lives here rather than three times over.

Lists are capped at 25 entries, keeping the newest ones. References grows without bound on a long thread and a mail server will reject an oversized header, so the tail — the nearest ancestors, which is what a client threads on — is the part worth keeping.

Summary

Functions

Renders an id for a header, or nil so the header can be omitted.

Renders a list of ids for a References header, or nil when empty.

Generates a new message id for a message sent from address.

Every id in a References-style value, oldest first.

The cap applied to reference chains.

Flattens several reference sets into one deduplicated, capped chain.

The bare id, brackets and whitespace stripped, or nil if there is none.

Functions

format(value)

@spec format(term()) :: binary() | nil

Renders an id for a header, or nil so the header can be omitted.

format_list(references)

@spec format_list(term()) :: [binary()] | nil

Renders a list of ids for a References header, or nil when empty.

generate(address)

@spec generate(binary() | nil) :: binary()

Generates a new message id for a message sent from address.

list(value)

@spec list(term()) :: [binary()]

Every id in a References-style value, oldest first.

Prefers bracketed ids; falls back to splitting on whitespace and commas for providers that hand over an unbracketed list.

max_references()

@spec max_references() :: pos_integer()

The cap applied to reference chains.

merge(reference_sets)

@spec merge([term()]) :: [binary()]

Flattens several reference sets into one deduplicated, capped chain.

normalize(value)

@spec normalize(term()) :: binary() | nil

The bare id, brackets and whitespace stripped, or nil if there is none.