📋 SPF Syntax Reference

Every SPF record is a TXT record beginning with v=spf1 followed by a sequence of mechanisms, modified by qualifiers, and optionally ended with a redirect or exp modifier. This reference covers every component of the SPF syntax defined in RFC 7208.

How an SPF Record Works

When a receiving server gets an email, it checks the sending IP against the sender domain's SPF record. Each mechanism is evaluated left to right. The first mechanism that matches determines the result. The qualifier on that mechanism determines whether it's a Pass, Fail, SoftFail, or Neutral outcome.

v=spf1 include:_spf.google.com ip4:203.0.113.5 -all
v=spf1: version header
include:…: mechanism
ip4:…: mechanism
-all: qualifier + mechanism

⚙️ Mechanisms

Mechanisms define which senders are authorised. They are evaluated left to right; the first match wins.

include DNS lookup
include:<domain>
View reference →
a DNS lookup
a[:<domain>][/prefix-length][//ipv6-prefix]
View reference →
mx DNS lookup
mx[:<domain>][/prefix-length][//ipv6-prefix]
View reference →
ip4
ip4:<ip-address>[/prefix-length]
View reference →
ip6
ip6:<ip6-address>[/prefix-length]
View reference →
ptr DNS lookup
ptr[:<domain>]
View reference →
exists DNS lookup
exists:<domain>
View reference →
all
[qualifier]all
View reference →

🔀 Modifiers

Modifiers change how SPF evaluation works. They are processed after all mechanisms.

redirect DNS lookup
redirect=<domain>
View reference →
exp DNS lookup
exp=<domain>
View reference →

🎛️ Qualifiers

Qualifiers prefix mechanisms to control the outcome when a mechanism matches.

+ (Pass)
+all
View reference →
- (Fail)
-all
View reference →
~ (SoftFail)
~all
View reference →
? (Neutral)
?all
View reference →

⚠️ The 10 DNS Lookup Limit

SPF allows a maximum of 10 DNS lookups per evaluation (RFC 7208 §4.6.4). Mechanisms that require DNS lookups are marked above. Exceeding 10 causes a permerror, which most receivers treat as a hard SPF failure. Use ip4: and ip6: where possible to stay under the limit.

🔧 Validate or Build Your SPF Record

Use these tools to check your current SPF record or build a new one from scratch.

SPF Checker → SPF Builder →