SPF record
Learn what an SPF record is, how it prevents email spoofing by authorizing sending mail servers, how to read and write SPF syntax, common setups for Google and Microsoft 365, and how to troubleshoot failures.
TL;DR
An SPF record (Sender Policy Framework) is a DNS TXT record that lists which mail servers are authorized to send email on behalf of your domain.
Receiving mail servers check SPF to decide if an incoming email claiming to be from you@example.com actually came from a server you've approved.
Without SPF, anyone can forge your domain in the From header and send spam or phishing email.
example.com) listing your authorized senders.user@example.com.example.com TXT and finds your SPF record.SPF checks the envelope sender (the
MAIL FROMaddress used during SMTP), not the visibleFrom:header. This is why SPF alone doesn't prevent display-name spoofing — that's what DMARC adds.
SPF records are TXT records that always start with v=spf1:
example.com. TXT "v=spf1 include:_spf.google.com ~all"| Mechanism | Meaning |
|---|---|
ip4:1.2.3.4 | Authorize a specific IPv4 address |
ip4:1.2.3.0/24 | Authorize an IPv4 CIDR range |
ip6:2001:db8::/32 | Authorize an IPv6 range |
include:spf.example.com | Merge in another domain's SPF record |
a | Authorize the domain's A/AAAA records |
mx | Authorize the domain's MX servers |
exists:%{i}._spf.example.com | Macro-based conditional lookup |
all | Match everything (used at the end) |
Each mechanism can have a qualifier prefix:
| Qualifier | Name | Effect |
|---|---|---|
+ (default) | Pass | Authorized — email is legitimate |
- | Fail (hard) | Not authorized — reject the email |
~ | Softfail | Not authorized — accept but mark as suspicious |
? | Neutral | No policy stated |
The all mechanism at the end is the catch-all for IPs not matched by earlier rules:
-all — reject everything else (strict, recommended once you're confident)~all — softfail everything else (safe starting point)?all — neutral (not recommended, no protection)Google Workspace
example.com. TXT "v=spf1 include:_spf.google.com ~all"Microsoft 365
example.com. TXT "v=spf1 include:spf.protection.outlook.com ~all"Multiple providers (e.g., Microsoft 365 + Mailchimp)
example.com. TXT "v=spf1 include:spf.protection.outlook.com include:servers.mcsv.net ~all"Custom mail server + Google
example.com. TXT "v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all"Strict — only your own IP, reject everything else
example.com. TXT "v=spf1 ip4:203.0.113.10 -all"dig example.com TXTnslookup -type=TXT example.comLook for the line starting with v=spf1 in the output.
SPF has a hard limit of 10 DNS lookups during evaluation. Each include:, a, and mx mechanism counts as one lookup. Nested includes count too.
Exceeding 10 lookups causes a PermError, which most receivers treat as a failure. Common causes:
include: statements chaining to other includesa and mx when ip4/ip6 would work fineIf you hit the limit, flatten your SPF record by replacing include: chains with direct ip4: entries, or use an SPF flattening service.
| Feature | SPF | DKIM | DMARC |
|---|---|---|---|
| What it checks | Sending server IP | Cryptographic signature on message | Alignment of SPF/DKIM with From header |
| Where it's published | example.com TXT | selector._domainkey.example.com TXT | _dmarc.example.com TXT |
| Survives forwarding | No — IP changes | Yes — signature travels with email | Depends on DKIM passing |
| Provides reporting | No | No | Yes (rua/ruf) |
| Stops spoofing alone | Partially | Partially | Yes (with p=reject) |
SPF, DKIM, and DMARC work together. SPF alone is not enough — use all three.
→ See also: DKIM Record, DMARC Record, TXT Record
Related: How to Set Up an SPF Record · DKIM Record · DMARC Record · MX Record · TXT Record · Free SPF Checker