SPF Syntax: The Complete Reference
An SPF record is one TXT string, evaluated left to right, first match wins. Every term is a qualifier glued to a mechanism, plus a couple of modifiers. This is every piece of that grammar.
SPF qualifiers
| Qualifier | Meaning |
|---|---|
| + | Pass (default) |
| - | Hardfail |
| ~ | Softfail |
| ? | Neutral |
| Term | Kind | Lookup? | Meaning |
|---|---|---|---|
| v=spf1 | version | no | Required first token. |
| ip4:1.2.3.4 | mechanism | no | Matches that IPv4 (CIDR ranges allowed). |
| ip6:... | mechanism | no | Matches an IPv6 address or range. |
| a / a:domain | mechanism | 1 | Matches the domain's A/AAAA records. |
| mx / mx:domain | mechanism | 1 | Matches the domain's MX hosts' addresses. |
| include:domain | mechanism | 1 | Evaluates another domain's SPF; a pass there is a pass here. |
| exists:domain | mechanism | 1 | Matches if the name resolves at all (rare, macro use). |
| ptr / ptr:domain | mechanism | 0 | Deprecated reverse-DNS match; remove it. |
| all | mechanism | no | Matches everything; its qualifier sets the default verdict. |
| redirect=domain | modifier | 1 | Replace evaluation with another domain's record. |
| exp=text | modifier | no | Explanation string for failures; rarely used. |
The ip4 and ip6 mechanisms take CIDR ranges, and the CIDR Calculator converts an address range into the exact notation an SPF record expects.
The qualifiers
+pass (default when no qualifier is written)-hard fail: receivers should reject~soft fail: accept but penalize; the common safe default on~all?neutral: no assertion either way
Evaluation in one paragraph
The receiver walks terms left to right against the connecting IP. First mechanism that matches
returns its qualifier's verdict and evaluation stops. If nothing matches, all
catches the remainder, which is why your terminal qualifier defines your posture. Every
include/a/mx/exists/redirect costs one of the
10 permitted lookups; exceeding them returns permerror, a
broken record. Test any change with the SPF checker.
Frequently asked questions
What does ~all mean in SPF?+
Softfail: senders failing SPF are marked suspicious but not rejected. -all hardfails them. ~all is the safe choice while tuning; -all is the enforcement choice.
Is +all ever correct?+
No. Plus-pass on everything means any server on earth may send as your domain. It is always a misconfiguration.
What is the difference between a mechanism and a modifier?+
Mechanisms match the sending IP and decide the result; modifiers like redirect= and exp= change evaluation or provide explanations without matching.
Related
Last verified: 2026-11-08