SPF Record Checker |
An SPF record is a TXT record that lists the servers allowed to send email for a domain. It starts with
v=spf1, ends with -all or ~all, and may use at most 10 DNS lookups;
more than that makes SPF fail. Senders are listed with ip4: for IPv4 and ip6: for
IPv6, and you can test whether an IPv4 or IPv6 address is allowed to send.
What Is an SPF Record?
SPF (Sender Policy Framework, RFC 7208) lets a domain publish which servers may send its email; receivers check the sending IP against it.
When a server receives a message, it takes the domain of the envelope sender (the MAIL FROM
address, also shown as Return-Path), reads that domain's SPF record and checks whether the connecting IP
is on the list. The answer is pass, fail, softfail,
neutral, or an error (PermError for a broken record,
TempError for a DNS timeout).
SPF doesn't look at the From address people see in their mail app. That's the job of DMARC, which requires SPF or DKIM to pass for a domain that matches the visible From. Check those records with the TXT lookup (DMARC and DKIM), and the receiving side with the MX lookup.
SPF Record Syntax, Term by Term
An SPF record is v=spf1, then mechanisms that match senders, then all for everyone else. Receivers read it left to right and stop at the first match.
| Term | Matches | DNS lookup? |
|---|---|---|
ip4:203.0.113.0/24 | An IPv4 address or range | No |
ip6:2001:db8::/32 | An IPv6 address or range | No |
a · a:host | The IPs of the domain's (or the named host's) A/AAAA records | 1 |
mx · mx:domain | The IPs of the domain's mail servers (MX) | 1 (the MX hosts' addresses, up to 10, are not counted) |
include:domain | Whatever the other domain's SPF record allows (a pass there is a match here) | 1, plus everything inside |
exists:domain | Matches if the name has an A record; used with macros like %{i} | 1 |
ptr | Reverse DNS of the sender ends in the domain. Slow and unreliable: RFC 7208 says not to use it | 1 |
all | Everyone not matched so far; always last | No |
redirect=domain | Use another domain's record instead, if nothing matched (ignored when all is present) | 1 |
exp=domain | A TXT record with the explanation sent back on fail | Not counted |
Each mechanism can start with a qualifier that sets the result when it matches:
| Qualifier | Result | What receivers do |
|---|---|---|
+ (default) | pass | Accept: the server is allowed |
- | fail | Reject, or apply the DMARC policy |
~ | softfail | Accept but mark as suspicious |
? | neutral | No opinion: treated like no SPF |
SPF record examples
| Setup | Record |
|---|---|
| Google Workspace only | v=spf1 include:_spf.google.com ~all |
| Microsoft 365 only | v=spf1 include:spf.protection.outlook.com -all |
| Google Workspace + a newsletter service | v=spf1 include:_spf.google.com include:servers.mcsv.net ~all |
| Own server + Microsoft 365 | v=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all |
| A domain that sends no email | v=spf1 -all |
Google Workspace and Microsoft 365 SPF Records
Google Workspace: include:_spf.google.com. Microsoft 365: include:spf.protection.outlook.com. A domain that uses both puts both in one record.
v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all
Each include costs 1 lookup plus whatever is inside the provider's record, and providers restructure
those records from time to time. The checker above shows the exact cost of each
include today. The official values are in Google Workspace Admin Help ("Set up SPF") and Microsoft Learn
("Set up SPF to help prevent spoofing"); Google's own examples end with ~all.
The 10 DNS Lookup Limit (PermError)
include, a, mx, ptr, exists and redirect each cost a lookup, including those inside includes; more than 10 and receivers return PermError, so SPF fails.
RFC 7208 (section 4.6.4) sets the limit so a single message can't make a receiver run dozens of DNS
queries. It also allows at most 2 void lookups: terms whose name returns no answer or
doesn't exist. A third one is also a PermError, which often happens after a service you removed
still has an include: in your record.
How to get back under 10:
- Remove includes for services you no longer use (old newsletter tools, a former mail host).
- Replace
aandmxwith the server'sip4:/ip6:addresses: zero lookups. - Remove
ptr: it costs a lookup and receivers may ignore it. - Send bulk mail from a subdomain (for example
news.example.com) with its own SPF record, so it gets its own 10 lookups.
What is SPF flattening?
Flattening replaces includes with the IP ranges they currently resolve to, so the record needs fewer lookups. The risk: providers change their IPs without notice, and a flattened record then blocks your own mail. Only flatten with a service that rebuilds the record automatically, and prefer removing unused includes first.
~all or -all? SoftFail vs Fail
-all tells receivers to reject other senders; ~all to accept but mark them. With DMARC at quarantine or reject, both lead to the DMARC policy.
~all: the safe default while you're still finding every service that sends for you; it's the value in Google's setup examples.-all: once the list is complete, and always for domains that send no email (v=spf1 -all).?all: protects nothing; only for testing.+all: never. It lets any server on the internet send as your domain.
A strict -all can make forwarded mail fail, because the forwarder's IP isn't in your record. DKIM survives forwarding, which is one more reason to set up DKIM alongside SPF.
Common SPF Errors and How to Fix Them
Two SPF records, more than 10 lookups and a missing all cause most SPF failures. The checker above flags each of these.
| Error | Fix |
|---|---|
| Two SPF records | Merge them into one v=spf1 record (PermError otherwise) |
| More than 10 DNS lookups | Remove unused includes, replace a/mx with IPs |
| More than 2 void lookups | Remove includes and a/mx terms whose names no longer exist |
| Include without an SPF record | Check the provider's current value; the include is a PermError |
Unknown term or typo (ip4 :, inlcude:) | Fix the syntax: any unknown mechanism is a PermError |
No all at the end | Add ~all or -all; without it the result is neutral |
+all or ?all | Use ~all or -all |
Terms after all | Move them before all: they're never read |
ptr mechanism | Replace it with ip4:/ip6: or a |
To build a corrected record (merged, under 10 lookups, with the right include for each service), use the SPF record generator: it starts from the record published now.
To see the SPF result a receiver actually gave a real message, paste its headers into the email header analyzer. If mail is rejected even though SPF passes, check the sending IP with the blacklist checker.
Do it yourself
Check an SPF Record with nslookup or dig
Windows Command Prompt
nslookup -type=txt example.com
Windows PowerShell
Resolve-DnsName example.com -Type TXT | Where-Object { $_.Strings -match "v=spf1" }
Mac / Linux dig
dig +short example.com txt | grep "v=spf1"
dig +short _spf.google.com txt
Look for the line starting with v=spf1, then repeat the query for each include: to count lookups by hand, which is what the checker does for you. Use the TXT type: the old SPF record type (99) is obsolete.
How This SPF Checker Works
| Query | Live DNS query (no cache) to the server you pick: Google, Cloudflare, Quad9, OpenDNS, DNS4EU, AdGuard, Control D, Yandex, or the domain's own authoritative servers |
| Includes | Every include: and redirect= is fetched live and expanded into the tree, with a loop guard |
| Counting | DNS lookups (max 10) and void lookups (max 2) per RFC 7208, section 4.6.4 |
| IP test | RFC 7208 check_host for ip4, ip6, a, mx, include, redirect and all. exists and ptr are not evaluated; the result says so when they could matter |
| Providers | Recognised from include names (Google Workspace, Microsoft 365, SendGrid, Mailchimp, Amazon SES…); no match, no label |
| Runs on | Our server in the US (AWS, N. Virginia) |
| What we keep | Lookups are not saved. Our server and Cloudflare keep standard access logs. |
Frequently Asked Questions
How do I check a domain's SPF record?
What does "too many DNS lookups" mean?
include, a, mx, ptr, exists and redirect counts, and so do the ones inside included records. Receivers then return PermError and SPF fails. Remove services you no longer use, or replace a and mx with ip4: ranges.Can a domain have two SPF records?
v=spf1 on the same name are invalid (RFC 7208, section 3.2) and make SPF fail with PermError. Merge them into one record with several include: terms.What is the SPF record for Google Workspace?
v=spf1 include:_spf.google.com ~all. If other services send email for your domain too, add their terms inside the same record, before ~all.What is the difference between ~all and -all?
~all (soft fail) asks receivers to accept mail from servers not listed but mark it as suspicious. -all (fail) asks them to reject it. With a DMARC policy at quarantine or reject, both lead to the DMARC policy being applied.Is SPF enough to stop spoofing?
Next steps