Spf (Spfcheck v0.1.0) View Source
Check SPF for a specific sender
and possible options.
The Spf.check/2
function takes a sender and possible options and returns an
evaluation context
that contains the verdict and
some statistics of the evaluation.
Example
iex> unless File.dir?("tmp"), do: File.mkdir("tmp")
iex> File.write("tmp/zone.txt", """
...> example.com TXT v=spf1 -all exp=why.%{d}
...> why.example.com TXT %{d}: %{i} is not one of our MTA's
...> """)
:ok
iex> ctx = Spf.check("example.com", dns: "tmp/zone.txt")
iex> {ctx.verdict, ctx.reason, ctx.explanation}
{:fail, "spf[0] -all", "example.com: 127.0.0.1 is not one of our MTA's"}
Link to this section Summary
Functions
Check SPF for given sender
and possible options.
Link to this section Functions
Specs
check(binary(), list()) :: Spf.Context.t()
Check SPF for given sender
and possible options.
Options include:
dns:
filepath or zonedata to pre-populate the context's DNS cachehelo:
the helo presented by sending MTA, defaults tosender
ip:
ipv4 or ipv6 address, in binary, of sending MTA, defaults to127.0.0.1
log:
a user log/4 function to relay notifications, defaults tonil
verbosity
how verbose the notifications should be (0..5), defaults to3
Examples
iex> zone = """
...> example.com TXT v=spf1 +all
...> """
iex> Spf.check("example.com", dns: zone) |> Map.get(:verdict)
:pass