How do you check your SPF record?
To check your SPF record, run three tests: look up the TXT records at your domain and confirm exactly one starts with v=spf1; count the DNS-querying terms, including nested includes, against the limit of 10; then send a real message and read the SPF result, the checked domain and DMARC alignment in the receiver's headers.
A record can look fine in DNS and still return permerror because of a hidden lookup overflow, and a passing check can be for your provider's domain rather than yours. This guide covers the commands, the RFC 7208 rules, what to read in Gmail and Outlook, and a routine for MSPs (managed service providers). To build a record from scratch, see how to create an SPF record; for the concepts, start with the SPF guide.
Key takeaways
- A valid SPF record is a single TXT record at the exact domain being checked, starting with
v=spf1. Two records producepermerror, which receivers treat as a broken record. include,a,mx,ptr,existsandredirecteach cost a DNS lookup, counted across every nested include. More than 10 is apermerror, and so is more than two void lookups.- Check a real message:
spf=passalone is not enough. Thesmtp.mailfromdomain must be yours, or a subdomain of it, for SPF to count towards DMARC. - SPF is not inherited by subdomains. Check the domain in the bounce address, which is often a subdomain or the provider's domain, not the From domain.
What are the three checks for an SPF record?
The three checks are a DNS check, an evaluation check and a message check. Run them in that order, because each depends on the one before. The table shows what each proves and what it cannot.
| Check | What you test | Tool | Proves | Does not prove |
|---|---|---|---|---|
| 1. Published record | TXT records at the domain | dig, nslookup, Resolve-DnsName |
One v=spf1 record exists with sane syntax |
That it evaluates within the limits |
| 2. Evaluation | Lookup count, void lookups, include chain | dig per include, an SPF analyzer |
Receivers can evaluate it without permerror |
That your senders' IPs are covered |
| 3. Real message | Authentication-Results, Received-SPF |
Gmail Show original, Outlook message details | Receivers return pass for a real sender, and whether it aligns |
Nothing more is needed for SPF |
The same pattern applies to the other two protocols: how to check if DKIM is working and how to check your DMARC policy.
Check 1: is the SPF record published correctly?
It is published correctly when a TXT query for the domain returns exactly one string that starts with v=spf1, followed by mechanisms and ending in an all term or a redirect. Look it up from outside your network, count the v=spf1 lines, then read the record for obvious syntax faults.
How do you look up an SPF record with dig, nslookup or Resolve-DnsName?
Query the TXT records at the domain itself, not at a prefix: SPF has no _spf style label of its own. On macOS or Linux use dig; on Windows use nslookup or PowerShell's Resolve-DnsName. Filter for v=spf1, because the same name usually also holds verification strings.
# macOS / Linux
dig +short TXT example.com | grep -i "v=spf1"
# Ask a public resolver to bypass a stale local cache
dig +short TXT example.com @1.1.1.1 | grep -i "v=spf1"
# Windows
nslookup -type=TXT example.com
Resolve-DnsName -Name example.com -Type TXT | Where-Object { $_.Strings -match "v=spf1" }
A healthy answer is one line:
"v=spf1 include:spf.protection.outlook.com include:_spf.mailer.example.net ip4:203.0.113.25 -all"
Long records may come back as several quoted strings on one line. RFC 7208 Section 3.3 says such strings are joined "without adding spaces", so check that a space exists at the end of one string or the start of the next. If the authoritative server (find it with dig +short NS example.com) shows a new value but a public resolver does not, you are waiting for the old record's TTL (time to live) to expire.
How many SPF records should a domain have?
Exactly one. RFC 7208 Section 4.5 says that if the record set "includes more than one record, check_host() produces the "permerror" result", and if it includes none, the result is none. Two v=spf1 lines do not combine; they break SPF for the whole domain.
The usual cause is a new provider's setup guide telling someone to "add an SPF record" when one already exists. Merge the mechanisms into a single record; multiple SPF records: how to merge them shows the method.
What does a quick syntax check look for?
Read the record left to right against a short list of faults that RFC 7208 treats as errors or that silently break the result. The full grammar is in the SPF syntax reference; this is the sanity pass.
- It starts with
v=spf1exactly, followed by a space.v=spf1include:orv=spf 1is not a record. - One
allat the end. Anything afterallis never evaluated.+allauthorises every server on the internet. - Mechanism spelling.
ip4:takes an address or CIDR range, not a hostname;include:takes a domain, not an IP. A typo such asinlcude:causespermerror. - No
ptr. RFC 7208 says it "SHOULD NOT be published", and it costs lookups. - Published as TXT. Section 3.1 says SPF records "MUST be published as a DNS TXT (type 16) Resource Record (RR)". The old SPF record type was discontinued; a record only in that type is invisible to receivers.
- Plain characters. Smart quotes or invisible characters pasted from a document break parsing.
Does each subdomain need its own SPF record?
Only if it sends mail or appears in a bounce address. SPF is checked at the exact domain in the MAIL FROM (or HELO) identity, and a subdomain does not inherit the parent's record. If a platform bounces from bounce.example.com, that name needs its own record, usually published by pointing it at the provider as its setup guide describes.
That is why a lookup at the apex is not always the right check. Take the domain from the smtp.mailfrom value of a real message (Check 3) and query that name too.
Check 2: does the record evaluate within the lookup limits?
It does when evaluating the whole record, including every nested include, needs no more than 10 DNS-querying terms and no more than two lookups that return nothing. Exceeding either limit returns permerror, and the record is broken for every receiver that enforces the limits, even though it looks valid in DNS.
How do you count SPF DNS lookups?
Count every include, a, mx, ptr and exists mechanism and every redirect modifier, in your record and in every record they pull in. RFC 7208 Section 4.6.4 says implementations "MUST limit the total number of those terms to 10" and must return permerror above it. ip4, ip6 and all cost nothing.
| Term | Costs a lookup? | Notes |
|---|---|---|
include: |
Yes, 1, plus every lookup inside the included record | The usual cause of overflow |
a, a:host |
Yes, 1 | |
mx, mx:host |
Yes, 1 | Each MX host resolved must stay within 10 address lookups |
ptr |
Yes, 1 | Should not be published at all |
exists: |
Yes, 1 | Common in provider macros |
redirect= |
Yes, 1 | Replaces the record; its lookups count too |
ip4:, ip6:, all |
No | Add IPs directly to save lookups |
exp= |
No | Only evaluated after a fail |
How do you walk the include chain?
Query each included domain in turn and count its DNS-querying terms, then repeat for any includes inside it. The total across all levels is what counts.
dig +short TXT example.com | grep -i "v=spf1"
# "v=spf1 include:spf.protection.outlook.com include:_spf.mailer.example.net mx -all"
dig +short TXT spf.protection.outlook.com | grep -i "v=spf1"
dig +short TXT _spf.mailer.example.net | grep -i "v=spf1"
# "v=spf1 include:_spf1.mailer.example.net include:_spf2.mailer.example.net -all"
In this example, the top level spends 3 (two includes and mx) and the mailer's include spends 2 more inside it, so the running total is 5 plus whatever the Microsoft include contains. Providers change their own records without notice, so a record at 9 can cross 10 overnight. The SPF analyzer on this site expands every level and gives the total in one step. If you are over, SPF too many DNS lookups covers the fixes, and SPF flattening explained covers the trade-offs of replacing includes with IPs.
What are void lookups, and why do they matter?
A void lookup is a DNS query in the evaluation that returns no answer: either an empty answer or a "name does not exist" (NXDOMAIN) response. RFC 7208 Section 4.6.4 says implementations "SHOULD limit "void lookups" to two", and that "Exceeding the limit produces a "permerror" result."
Void lookups usually point to dead configuration: an include for a former provider, an a: term for a retired host, or a typo. Test each with dig; an empty answer or NXDOMAIN is a term to remove. Separately, Section 5.2 says an include pointing at a domain with no SPF record makes the include return permerror, so a dead include can break the whole record on its own.
Check 3: does SPF pass on a real message?
Send a message from each sending source to an external mailbox, open the full header and read the receiver's SPF result. You want spf=pass in Authentication-Results, or Received-SPF: pass, with the checked domain being yours. Then confirm whether that domain aligns with the From domain, because only aligned SPF counts for DMARC.
Receivers record SPF in two header fields. RFC 8601 defines Authentication-Results, where SPF uses smtp.mailfrom or smtp.helo to show which identity was checked. RFC 7208 Section 9.1 defines Received-SPF, which carries more detail: client-ip, envelope-from, helo, identity, receiver and, sometimes, the mechanism that matched.
Received-SPF: pass (mx.receiver.example: domain of bounce@example.com
designates 203.0.113.25 as permitted sender)
client-ip=203.0.113.25; envelope-from="bounce@example.com";
helo=mail.example.com; identity=mailfrom; receiver=mx.receiver.example;
Authentication-Results: mx.receiver.example;
spf=pass (sender IP is 203.0.113.25) smtp.mailfrom=example.com;
dkim=pass header.d=example.com;
dmarc=pass header.from=example.com
How do you check SPF in Gmail?
Send a message to a Gmail account and open its full header. Google's header instructions say: in a browser, open the email, "Next to Reply, click More" and select "Show original". The full header opens in a new window. Find the Received-SPF and Authentication-Results lines that Google added.
Read only the receiver's lines at the top; copies lower down come from earlier hops. The email header analyzer lays the fields out, and how to read email headers explains the rest.
How do you check SPF in Outlook and Microsoft 365?
In new Outlook, open the message, select More actions, then View and View message details, as Microsoft Support describes. Exchange Online writes SPF in its Authentication-Results line in the form spf=pass (sender IP is 192.168.0.1) smtp.mailfrom=contoso.com.
Microsoft's anti-spam message headers reference defines smtp.mailfrom as "The domain of the MAIL FROM address (also known as the 5321.MailFrom address, P1 sender, or envelope sender)", the address used for bounces. It also describes permerror as "A permanent error occurred. For example, the domain has a badly formatted SPF record." The same line carries compauth, Microsoft's composite verdict based on the From domain.
Which identity did the receiver check: MAIL FROM or HELO?
Usually MAIL FROM, the envelope sender shown as smtp.mailfrom or envelope-from. RFC 7208 also recommends checking the HELO name, shown as smtp.helo or identity=helo. When the MAIL FROM is empty, as in bounce messages, SPF builds the identity from postmaster and the HELO name instead.
A fail on identity=helo points to the sending server's hostname not being covered, not the domain's main record. For DMARC, only the MAIL FROM result counts: RFC 9989 Section 3.2.4 says "DMARC relies solely on SPF validation of the MAIL FROM identity."
Did SPF align for DMARC?
SPF aligns when the smtp.mailfrom domain matches the From domain: exactly, for strict alignment (aspf=s), or with the same Organizational Domain, for the default relaxed alignment. smtp.mailfrom=bounce.example.com with From example.com aligns under relaxed rules; smtp.mailfrom=mailer.example.net does not, however cleanly SPF passes.
Many platforms use their own bounce domain by default, so SPF passes for them and never for you. Then DMARC depends on aligned DKIM, or on setting up a custom bounce (return-path) domain on the platform. Why DMARC fails when SPF passes works through the cases, and DMARC alignment explained covers the rules.
What does each SPF result mean?
RFC 7208 defines seven results, and each points to a specific action. Match the value from the header to a row. Note that receivers decide what to do with each result; the RFC's Section 8 gives guidance, not orders.
| Result | What it means (RFC 7208 Sec. 2.6 and 8) | What to do |
|---|---|---|
pass |
The sending IP is authorised for the checked domain | Confirm the domain is yours and aligns with From |
fail |
The domain says the IP is not authorised (-all matched). Receivers may reject with 550 5.7.1 |
Add the missing sender, or find out who is spoofing you |
softfail |
"A weak statement" that the IP is probably not authorised (~all matched). Receivers "SHOULD NOT reject the message based solely on this result" |
Same as fail for a legitimate source: add it |
neutral |
The domain makes no assertion (?all, or no mechanism matched and no all). Treated "exactly like" none |
Finish the record with ~all or -all |
none |
No SPF record found, or no valid domain to check | Publish a record at the domain shown in smtp.mailfrom |
temperror |
A transient error, usually DNS. Receivers may defer with 451 4.4.3 |
Check your DNS servers' availability and response times |
permerror |
The record "could not be correctly interpreted". RFC 7208 says it "definitely requires DNS operator intervention" | Fix the record: two records, over 10 lookups, void lookups or syntax |
For DMARC, only pass counts, and only when aligned. The difference between ~all and -all in practice is covered in SPF softfail vs hardfail with DMARC.
What are the most common SPF record problems?
Most broken SPF records fail in one of eight ways, and every one is visible with a dig lookup, a lookup count or a single header. Check all eight when you take over a domain.
| Problem | How it shows up | Fix |
|---|---|---|
Two v=spf1 records |
permerror everywhere |
Merge into one record |
| More than 10 DNS lookups | permerror, often at some receivers before others notice |
Remove dead includes, replace a and mx with ip4, review SPF best practices |
| Dead include or typo | Void lookups or include permerror |
Remove or correct the term |
| Missing sender | softfail or fail for a legitimate platform |
Add the provider's include or IPs |
| Record on the wrong name | none for the bounce domain |
Publish at the smtp.mailfrom domain, which may be a subdomain |
| Strings joined without a space | permerror or a mechanism that never matches |
Add the missing space between quoted strings |
+all or ?all |
Anyone passes, or neutral |
End with ~all or -all |
| SPF passes for the provider only | spf=pass but dmarc=fail |
Set a custom bounce domain or rely on aligned DKIM |
Forwarded mail is a separate case: SPF evaluates the forwarder's IP and usually fails, and no change to your record fixes that. DMARC and email forwarding explains why aligned DKIM carries forwarded mail.
How should an MSP check SPF across a client portfolio?
Script the DNS check across every client domain, run a lookup count on each record, and use DMARC aggregate reports for the message check, because a test email per sender per client does not scale. Run the routine monthly and after every DNS or provider change.
A short loop gives a record inventory from a plain list of domains:
while read d; do
r=$(dig +short TXT "$d" | grep -i '"v=spf1')
n=$(printf '%sn' "$r" | grep -c .)
echo "$d | records=$n | $r"
done < client-domains.txt
Then work through the output:
- Flag
records=0andrecords=2or more. No record meansnone; two meanpermerror. - Count lookups for every record with an analyzer, and flag anything at 8 or above as at risk from provider changes.
- Flag
+all,?all,ptrand missingallterms. - Lock down parked domains with
v=spf1 -alland a DMARC record atp=reject. - Compare authorised senders with reality. DMARC aggregate reports list every source IP sending as each domain, with its SPF result and checked domain. Sources failing SPF are either missing from the record or not legitimate.
- Keep evidence. Store the
digoutput and lookup count with each change ticket.
Step 5 is where the work is at scale. DMARC AI is a multi-tenant DMARC platform for MSPs that processes the aggregate reports for every client domain and uses AI to classify sending sources, so a sender failing SPF shows up without reading XML. For what SPF does and why DMARC needs it, see what is SPF.
FAQ
How do I know if my SPF record is valid?
Run dig +short TXT yourdomain or Resolve-DnsName -Name yourdomain -Type TXT and confirm exactly one string starts with v=spf1. Then count DNS-querying terms across all includes: 10 or fewer, with no more than two void lookups. Finally, send a test message and confirm the receiver's header shows spf=pass.
How do I look up an SPF record without a tool?
Use the command line. On macOS or Linux, dig +short TXT example.com lists the TXT records at the domain; on Windows, nslookup -type=TXT example.com does the same. Look for the line starting with v=spf1. SPF records live at the domain itself, not under a prefix such as _dmarc.
Why does my SPF record pass but DMARC fails?
Because SPF passed for a domain that does not align with your From domain. Check smtp.mailfrom in the header: if it shows your email platform's bounce domain, SPF passed for the platform, not for you. Set up a custom bounce domain on the platform, or make sure it signs DKIM with your domain.
How long after changing SPF can I check it?
Query the authoritative name server straight away to confirm the new record. Public resolvers and receivers see it once the old record's TTL expires, so check the TTL your DNS host shows. Send test messages after that, and confirm in DMARC aggregate reports from the following days.
Final thoughts
Checking an SPF record is three questions: is exactly one record published, can receivers evaluate it within 10 lookups and two void lookups, and does real mail pass on a domain that aligns with From? The lookup answers the first, a walk of the include chain the second, and only headers and aggregate reports the third. For a portfolio, script the first two and let the reports do the third.