Karta.Auth.DMARC.Record (Karta v1.0.0)

A DMARC policy record (RFC 9989 §4.7 and §4.8).

The record must start with v=DMARC1 (case-sensitive); tags are name=value pairs separated by ;. Unknown tags are ignored, and so is a tag whose value is not valid: it keeps its default. pct is no longer part of DMARC (RFC 9989 Appendix A.6) and is ignored like any unknown tag.

Fields: p, sp, np (:none, :quarantine, :reject or nil), adkim, aspf (:relaxed by default, or :strict), psd (:y, :n or :u, the default), t (test mode, false by default), rua and ruf (the reporting URIs that are valid), fo.

valid is false when p is missing or not valid, or sp or np is present but not valid. Such a record is used as p=none when it has a valid rua, and not at all otherwise (§4.10.1); policy/1 says which.

Summary

Functions

True when a TXT record is a DMARC record: its first tag is v=DMARC1.

Parses a DMARC record: {:ok, record}, or :error when it is not one.

How the record applies: {:ok, record} (a record without a valid policy but with a valid rua becomes p=none, without sp and np), or :ignore (no valid policy and no rua: no DMARC processing).

Types

policy()

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

t()

@type t() :: %Karta.Auth.DMARC.Record{
  adkim: :relaxed | :strict,
  aspf: :relaxed | :strict,
  fo: String.t() | nil,
  np: policy() | nil,
  p: policy() | nil,
  psd: :y | :n | :u,
  rua: [String.t()],
  ruf: [String.t()],
  sp: policy() | nil,
  t: boolean(),
  valid: boolean()
}

Functions

dmarc?(text)

@spec dmarc?(binary()) :: boolean()

True when a TXT record is a DMARC record: its first tag is v=DMARC1.

parse(text)

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

Parses a DMARC record: {:ok, record}, or :error when it is not one.

policy(record)

@spec policy(t()) :: {:ok, t()} | :ignore

How the record applies: {:ok, record} (a record without a valid policy but with a valid rua becomes p=none, without sp and np), or :ignore (no valid policy and no rua: no DMARC processing).