SPF Record Checker

Look up, validate and understand a domain's SPF record.
More Tools

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.

Diagram: a receiving server looks up the SPF record of example.com, v=spf1 ip4:203.0.113.0/24 -all, and finds that the sender 203.0.113.7 is inside the range, so SPF passes
SPF is a guest list published in DNS. (Documentation addresses.)

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.

Diagram reading an SPF record left to right: v=spf1, include, ip4, mx and -all, with -all meaning reject and ~all meaning soft fail
Each mechanism adds senders; the final all decides about everyone else.
TermMatchesDNS lookup?
ip4:203.0.113.0/24An IPv4 address or rangeNo
ip6:2001:db8::/32An IPv6 address or rangeNo
a · a:hostThe IPs of the domain's (or the named host's) A/AAAA records1
mx · mx:domainThe IPs of the domain's mail servers (MX)1 (the MX hosts' addresses, up to 10, are not counted)
include:domainWhatever the other domain's SPF record allows (a pass there is a match here)1, plus everything inside
exists:domainMatches if the name has an A record; used with macros like %{i}1
ptrReverse DNS of the sender ends in the domain. Slow and unreliable: RFC 7208 says not to use it1
allEveryone not matched so far; always lastNo
redirect=domainUse another domain's record instead, if nothing matched (ignored when all is present)1
exp=domainA TXT record with the explanation sent back on failNot counted

Each mechanism can start with a qualifier that sets the result when it matches:

QualifierResultWhat receivers do
+ (default)passAccept: the server is allowed
-failReject, or apply the DMARC policy
~softfailAccept but mark as suspicious
?neutralNo opinion: treated like no SPF

SPF record examples

SetupRecord
Google Workspace onlyv=spf1 include:_spf.google.com ~all
Microsoft 365 onlyv=spf1 include:spf.protection.outlook.com -all
Google Workspace + a newsletter servicev=spf1 include:_spf.google.com include:servers.mcsv.net ~all
Own server + Microsoft 365v=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all
A domain that sends no emailv=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.

An SPF include tree with a lookup counter showing 7 of the 10 allowed DNS lookups.
Every include counts, and so does everything inside it.

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 a and mx with the server's ip4:/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.

ErrorFix
Two SPF recordsMerge them into one v=spf1 record (PermError otherwise)
More than 10 DNS lookupsRemove unused includes, replace a/mx with IPs
More than 2 void lookupsRemove includes and a/mx terms whose names no longer exist
Include without an SPF recordCheck 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 endAdd ~all or -all; without it the result is neutral
+all or ?allUse ~all or -all
Terms after allMove them before all: they're never read
ptr mechanismReplace 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

QueryLive 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
IncludesEvery include: and redirect= is fetched live and expanded into the tree, with a loop guard
CountingDNS lookups (max 10) and void lookups (max 2) per RFC 7208, section 4.6.4
IP testRFC 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
ProvidersRecognised from include names (Google Workspace, Microsoft 365, SendGrid, Mailchimp, Amazon SES…); no match, no label
Runs onOur server in the US (AWS, N. Virginia)
What we keepLookups are not saved. Our server and Cloudflare keep standard access logs.

Frequently Asked Questions

How do I check a domain's SPF record?
Type the domain above and click Check. You'll see the record, what each term means, how many of the 10 allowed DNS lookups it uses (with every include expanded), and any errors with the fix. You can then test whether a given IP address may send email for the domain.
What does "too many DNS lookups" mean?
The record needs more than 10 DNS lookups to check: each 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?
No. Two TXT records starting with 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?
No. SPF checks the hidden envelope sender (Return-Path), not the From address people see. Add DKIM and a DMARC policy to protect the visible From address.

Next steps

Related Tools

SPF Record Generator
Create or fix a record, with a live 10-lookup check.
TXT Lookup
DMARC, DKIM and verification records.
MX Lookup
The servers that receive a domain's email.
Email Header Analyzer
The SPF, DKIM and DMARC results of a real message.
IP Blacklist Checker
Is a sending IP on spam blacklists?