MailAuth.DMARC.Record (MailAuth v0.1.0)

Copy Markdown View Source

A DMARC policy record (RFC 9989).

Fields:

  • :domain: where the record was found, without the _dmarc. prefix
  • :p, :sp, :np: the policies, :none, :quarantine or :reject, or nil when the tag is missing or not valid
  • :adkim, :aspf: :relaxed (the default) or :strict
  • :psd: :yes, :no or :unknown (the default)
  • :testing?: true for t=y
  • :rua, :ruf: report addresses, as written
  • :fo: the failure reporting options, as written
  • :warnings: problems found while parsing, such as :missing_policy

Unknown tags, and the pct, rf and ri tags that RFC 9989 removed, are ignored. A record without a valid p tag, or with an sp or np tag that is not valid, is read as p=none when it has a rua address, and does not apply otherwise, as RFC 9989 section 4.10.1 says.

Summary

Functions

Parses a TXT record. Returns :error unless its first tag is v=DMARC1.

True when the record has a p tag and valid sp and np tags, if any. RFC 9989 reads a record without them as p=none only when it has a report address; otherwise DMARC does not apply.

Types

policy()

@type policy() :: :none | :quarantine | :reject

t()

@type t() :: %MailAuth.DMARC.Record{
  adkim: :relaxed | :strict,
  aspf: :relaxed | :strict,
  domain: String.t() | nil,
  fo: String.t() | nil,
  np: policy() | nil,
  p: policy() | nil,
  psd: :yes | :no | :unknown,
  rua: [String.t()],
  ruf: [String.t()],
  sp: policy() | nil,
  testing?: boolean(),
  warnings: [atom()]
}

Functions

parse(txt, domain \\ nil)

@spec parse(binary(), String.t() | nil) :: {:ok, t()} | :error

Parses a TXT record. Returns :error unless its first tag is v=DMARC1.

valid_policy?(record)

@spec valid_policy?(t()) :: boolean()

True when the record has a p tag and valid sp and np tags, if any. RFC 9989 reads a record without them as p=none only when it has a report address; otherwise DMARC does not apply.