Sovite.SMTP.DSNParams (sovite v0.6.0)

Copy Markdown View Source

The parameters of the SMTP DSN extension (RFC 3461 §4): NOTIFY and ORCPT on RCPT, RET and ENVID on MAIL.

iex> Sovite.SMTP.DSNParams.parse_notify("SUCCESS,FAILURE")
{:ok, [:success, :failure]}
iex> Sovite.SMTP.DSNParams.parse_orcpt("rfc822;bob+2Bwork@example.com")
{:ok, {"rfc822", "bob+work@example.com"}}
iex> Sovite.SMTP.DSNParams.encode_orcpt({"rfc822", "bob+work@example.com"})
"rfc822;bob+2Bwork@example.com"

ENVID and the address in ORCPT are xtext (Sovite.SMTP.XText). For internationalized addresses ORCPT has the utf-8 address type (RFC 6533 §3), where characters are escaped as \x{HEX} instead: utf-8;j\x{FC}rgen@example.com. With SMTPUTF8 the non-ASCII characters may also be sent as they are.

Decoded values never contain control characters.

Summary

Types

NOTIFY: :never, or when to send a notification. Without NOTIFY, a server sends failure and (at its choice) delay notifications.

ORCPT: the address type, lower-cased ("rfc822", "utf-8", ...), and the decoded address, as the first client gave it.

RET: return the whole message in a failure notification, or only its headers.

Functions

Encodes an ENVID value.

Encodes a NOTIFY value.

Encodes an ORCPT value. A utf-8 address keeps its non-ASCII characters with smtputf8: true, and is escaped otherwise.

Encodes a RET value.

The ORCPT for an address: rfc822 for an ASCII one, utf-8 for an internationalized one.

Parses an ENVID value, at most 100 characters of xtext.

Parses a NOTIFY value: NEVER, or a comma-separated list.

Parses an ORCPT value. Non-ASCII characters in a utf-8 address are accepted only with utf8: true, in a transaction with SMTPUTF8.

Parses a RET value.

Types

notify()

@type notify() :: :never | [:success | :failure | :delay, ...]

NOTIFY: :never, or when to send a notification. Without NOTIFY, a server sends failure and (at its choice) delay notifications.

orcpt()

@type orcpt() :: {type :: String.t(), address :: String.t()}

ORCPT: the address type, lower-cased ("rfc822", "utf-8", ...), and the decoded address, as the first client gave it.

ret()

@type ret() :: :full | :hdrs

RET: return the whole message in a failure notification, or only its headers.

Functions

encode_envid(envid)

@spec encode_envid(String.t()) :: String.t()

Encodes an ENVID value.

encode_notify(keywords)

@spec encode_notify(notify()) :: String.t()

Encodes a NOTIFY value.

encode_orcpt(arg, opts \\ [])

@spec encode_orcpt(orcpt(), keyword()) :: String.t()

Encodes an ORCPT value. A utf-8 address keeps its non-ASCII characters with smtputf8: true, and is escaped otherwise.

encode_ret(atom)

@spec encode_ret(ret()) :: String.t()

Encodes a RET value.

orcpt(address)

@spec orcpt(String.t()) :: orcpt()

The ORCPT for an address: rfc822 for an ASCII one, utf-8 for an internationalized one.

parse_envid(value)

@spec parse_envid(String.t()) :: {:ok, String.t()} | :error

Parses an ENVID value, at most 100 characters of xtext.

parse_notify(value)

@spec parse_notify(String.t()) :: {:ok, notify()} | :error

Parses a NOTIFY value: NEVER, or a comma-separated list.

parse_orcpt(value, opts \\ [])

@spec parse_orcpt(String.t(), keyword()) :: {:ok, orcpt()} | :error

Parses an ORCPT value. Non-ASCII characters in a utf-8 address are accepted only with utf8: true, in a transaction with SMTPUTF8.

parse_ret(value)

@spec parse_ret(String.t()) :: {:ok, ret()} | :error

Parses a RET value.