Expand description

A library implementing the Sender Policy Framework (SPF) specification, version 1, described in RFC 7208.

This library provides an API for checking whether an email sending host is authorised to use some mail domain according to SPF policy published in the DNS.


The function evaluate_sender is the main public API item. It allows checking the MAIL FROM and HELO identities according to the specification.

In addition, the function expand_explain_string allows performing macro expansion on explain strings (macro strings).

The above functions both require to be passed a Lookup implementation, which serves as a DNS resolver. The Lookup trait allows you to plug in any DNS resolver yourself, by providing an appropriate implementation. See the module lookup for more.

As a convenience, a Lookup implementation for the Trust-DNS resolver can be made available by enabling the Cargo feature trust-dns-resolver.

Cargo features

The feature trust-dns-resolver can be enabled to make a Lookup implementation available for the asynchronous Tokio-based trust_dns_resolver::TokioAsyncResolver.

The default feature tokio-timeout enables timeout logic using the Tokio time module. With this feature, the query functions will abort after the configured timeout. If you want to use a different async runtime, you can disable this feature and implement timeouts yourself (for example, as part of the Lookup implementation). Thus you can use this library without depending on Tokio at all.


Abstractions for DNS lookups.

Tracing information gathered during SPF query execution.


An SPF query configuration.

A builder for SPF query configurations.

A syntactically valid, normalised domain name.

The result of macro-expanding an explain string.

An error indicating that a query parameter could not be parsed.

The result of evaluating an SPF query.

A sender identity.


Causes of an SPF query error result.

Errors that may occur during query evaluation.

An explanation of why a query evaluated to a Fail result.

The result of an SPF evaluation.

The cause that led to an SPF result.


Performs an SPF query and evaluation for some sender identity.

Performs macro expansion on an explain string.