SPFInfo
Toggle sidebar
SPF Record Syntax

Domains define zero or more mechanisms. Mechanisms can be used to describe the set of hosts which are designated outbound mailers for the domain.

all
ip4
ip6
a
mx
ptr
exists
include

Domains may also define modifiers. Each modifier can appear only once.

redirect
exp
Mechanisms

Mechanisms can be prefixed with one of four qualifiers:

+
Pass
-
Fail
~
SoftFail
?
Neutral

If a mechanism results in a hit, its qualifier value is used. The default qualifier is "+", i.e. "Pass". For example:

"v=spf1 -all" "v=spf1 a -all" "v=spf1 a mx -all" "v=spf1 +a +mx -all"

Mechanisms are evaluated in order. If no mechanism or modifier matches, the default result is "Neutral".

If a domain has no SPF record at all, the result is "None". If a domain has a temporary error during DNS processing, you get the result "TempError". If some kind of syntax or evaluation error occurs, the result is "PermError".

Evaluation Results
Result Explanation Intended Action
Pass The SPF record designates the host to be allowed to send accept
Fail The SPF record has designated the host as NOT being allowed to send reject
SoftFail The SPF record has designated the host as NOT being allowed to send but is in transition accept but mark
Neutral The SPF record specifies explicitly that nothing can be said about validity accept
None The domain does not have an SPF record or the SPF record does not evaluate to a result accept
PermError A permanent error has occured (eg. badly formatted SPF record) unspecified
TempError A transient error has occured accept or reject
The "all" mechanism
all

This mechanism always matches. It usually goes at the end of the SPF record.

Examples
"v=spf1 mx -all"

Allow domain's MXes to send mail for the domain, prohibit all others.

"v=spf1 -all"

The domain sends no mail at all.

"v=spf1 +all"

The domain owner thinks that SPF is useless and/or doesn't care.

The "ip4" mechanism
ip4:<ip4-address>
ip4:<ip4-network>/<prefix-length>

The ip4 mechanism matches if the sender's IPv4 address is in the specified range. If no prefix-length is given, /32 is assumed.

Examples
"v=spf1 ip4:192.168.0.1/16 -all"

Allow any IP address between 192.168.0.1 and 192.168.255.255.

"v=spf1 ip4:1.2.3.4 -all"

Allow only 1.2.3.4.

The "ip6" mechanism
ip6:<ip6-address>
ip6:<ip6-network>/<prefix-length>

The ip6 mechanism matches if the sender's IPv6 address is in the specified range.

Examples
"v=spf1 ip6:1080::8:800:200C:417A/96 -all"

Allow any IPv6 address in the /96 subnet.

The "a" mechanism
a
a/<prefix-length>
a:<domain>
a:<domain>/<prefix-length>

All the A records for domain are tested. If the client IP is found among them, this mechanism matches. If connection is over IPv6, AAAA lookup is performed.

Examples
"v=spf1 a -all"

The current-domain is used.

"v=spf1 a:example.com -all"

Explicitly list domain.

The "mx" mechanism
mx
mx/<prefix-length>
mx:<domain>
mx:<domain>/<prefix-length>

All the A records for all the MX records for domain are tested. If the client IP is found among them, this mechanism matches.

Examples
"v=spf1 mx -all"

Allow domain's MXes.

The "ptr" mechanism
ptr
ptr:<domain>

The hostname(s) for the client IP are looked up using PTR queries. If a valid hostname ends in domain, it matches. Avoid using this due to expensive DNS lookups.

Examples
"v=spf1 ptr -all"

Allow all machines in domain.

The "exists" mechanism
exists:<domain>

Perform an A query on the provided domain. If a result is found, it matches.

Examples
"v=spf1 exists:example.com -all"

Check if example.com resolves.

The "include" mechanism
include:<domain>

The specified domain is searched for a match. If the lookup does not return a match or an error, processing proceeds to the next directive.

Examples
"v=spf1 include:example.com -all"

Include example.com policies.

Modifiers

Modifiers are optional. A modifier may appear only once per record. Unknown modifiers are ignored.

The "redirect" modifier
redirect=<domain>

The SPF record for domain replaces the current record. Useful for sharing one policy across multiple domains.

The "exp" modifier
exp=<domain>

If an SMTP receiver rejects a message, it can include an explanation string fetched from a TXT lookup of the specified domain.