Karta. Auth. SPF
(Karta v1.0.0)
SPF (RFC 7208): whether a domain authorises the client that sent a
message, by its check_host() function (§4).
mail_from/4checks the MAIL FROM identity: the sender's domain, or for the null senderpostmaster@the HELO name (§2.4).helo/3checks the HELO identity (§2.3).check_host/4is the function itself.
Every mechanism (all, include, a, mx, ptr, ip4, ip6,
exists), both modifiers (redirect, exp) and every macro are
implemented, and checked against the SPF project's RFC 7208 test suite.
Limits (§4.6.4), so that a record cannot make Karta do unbounded
work: at most 10 terms that look up DNS (include, a, mx, ptr,
exists, redirect; the 11th is a permerror), at most 2 of their
lookups that find nothing (permerror), at most 10 MX records per mx
(more is a permerror) and 10 PTR names per ptr or %{p} (the rest
are ignored). Each lookup goes through Karta.DNS with its cache and
the resolver's own timeouts; with :deadline the whole check also
stops at that time, with a temperror.
Results are Karta.Auth.SPF.Results. A DNS error is a temperror,
never a negative answer.
Options:
:dns- options forKarta.DNS.lookup/3(:resolver,:cache);:helo- the HELO name, for%{h}(mail_from/4andhelo/3set it);:receiver- the receiving host's name, for%{r}(defaultunknown);:now- Unix seconds, for%{t};:deadline- aSystem.monotonic_time(:millisecond)after which no lookup starts (default: no bound beyond the limits);:explain- look up the explanation of afail(defaultfalse);:default_explanationis used when there is none (defaultnil);:static- a check of a domain's configuration rather than of a message: a macro orptrthat evaluation reaches gives:unknown(Karta.IPPools.SPF).
Summary
Functions
check_host(<ip>, <domain>, <sender>) (RFC 7208 §4): the result for
ip sending as sender (local@domain), with the record of domain.
Checks the HELO identity: postmaster@<helo> against the HELO name's record.
Checks the MAIL FROM identity: sender is the envelope sender, or
nil (or "") for the null reverse path, in which case
postmaster@<helo> is checked.
Functions
@spec check_host(:inet.ip_address(), String.t(), String.t(), keyword()) :: Karta.Auth.SPF.Result.t()
check_host(<ip>, <domain>, <sender>) (RFC 7208 §4): the result for
ip sending as sender (local@domain), with the record of domain.
@spec helo(:inet.ip_address(), String.t() | nil, keyword()) :: Karta.Auth.SPF.Result.t()
Checks the HELO identity: postmaster@<helo> against the HELO name's record.
@spec mail_from(:inet.ip_address(), String.t() | nil, String.t() | nil, keyword()) :: Karta.Auth.SPF.Result.t()
Checks the MAIL FROM identity: sender is the envelope sender, or
nil (or "") for the null reverse path, in which case
postmaster@<helo> is checked.