SPF Record Explained: Syntax, Lookup Limits, and the Errors That Break Delivery
AIClicks Research · October 14, 2026
SPF (Sender Policy Framework) is the oldest of the three email authentication protocols, and the one most likely to be broken on your domain right now. It's a single DNS TXT record — deceptively simple — that lists which servers are allowed to send mail as you.
The problem: that single record has a 10-DNS-lookup limit, a qualifier system most people misunderstand, and include chains that silently balloon past the limit as vendors nest their own includes inside yours. When SPF breaks, it doesn't always fail loudly. It fails with permerror — and receivers treat that as 'no valid SPF,' which torpedoes your DMARC alignment.
This guide covers SPF syntax from first principles, the lookup limit that breaks most records, the qualifier decision (-all vs ~all), and the common errors our scanner finds in the wild. By the end you'll be able to read any SPF record at a glance and write one that actually works.
What SPF does (and doesn't do)
When a mail server receives a message claiming to be from your domain, SPF lets it ask a simple question: is the connecting IP address authorized to send mail for this domain? The receiver looks up your SPF TXT record, walks through its mechanisms, and gets one of four answers: pass, fail, softfail, or neutral — plus three error states (temperror, permerror, none).
What SPF doesn't do: it doesn't encrypt anything, it doesn't verify message content, and — critically — it checks the envelope sender (Return-Path), not the visible From header your recipients see. That's why SPF alone can't stop spoofing: an attacker can pass SPF with their own domain in the envelope while showing your domain in the From header. DMARC exists to close this gap by requiring alignment between the two.
SPF also breaks on forwarding. When someone auto-forwards your email through their own server, the forwarder's IP isn't in your SPF record — so SPF fails. This is by design, and it's why DMARC accepts either SPF or DKIM passing: DKIM signatures survive forwarding, SPF doesn't. Together they cover both paths.
SPF syntax, mechanism by mechanism
An SPF record always starts with v=spf1, followed by space-separated mechanisms and modifiers, ending with a default qualifier. Example: v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:spf.protection.outlook.com -all
The mechanisms, in the order receivers evaluate them: ip4 and ip6 match specific addresses or CIDR ranges — use these for servers with static IPs you control. a matches if the connecting IP equals your domain's A record; mx matches if it equals one of your MX records. These two are convenient but each costs a DNS lookup, and mx can trigger additional lookups per MX host.
include is the powerful one: it pulls in another domain's entire SPF record. include:_spf.google.com means 'everything Google authorizes, I authorize too.' This is how SaaS email works — but each include costs at least one lookup, and that included record may contain its own includes, nesting deeper. exists is rarely used: it does a DNS lookup against a constructed hostname, mainly for advanced macros.
Finally, the qualifier prefix on each mechanism: + (pass, the default if omitted), - (fail), ~ (softfail), ? (neutral). The last mechanism is typically the default policy: -all means 'fail everything not matched above' (hard fail), ~all means 'softfail everything else' (accept but mark), ?all is neutral (no opinion). +all authorizes the entire internet — never use it; it's worse than no SPF at all because it actively vouches for attackers.
The 10-lookup limit: SPF's silent killer
RFC 7208 section 10.1: SPF implementations must limit DNS lookups to 10 during evaluation. Exceed it and you get permerror — permanent error — which receivers treat as 'no usable SPF record.' Your carefully crafted policy becomes worthless.
What counts: each include, a, mx, ptr, exists, and redirect triggers at least one lookup. But mx and ptr can trigger more — mx looks up each MX hostname's A record, so 3 MX hosts means 1 + 3 lookups. Nested includes multiply: if your record has 4 includes and each of those has 3 includes, you're at 13 before you start.
This is the #1 SPF failure our scanner finds. The typical story: a company starts with Google Workspace (1 include), adds Mailchimp (1 more), adds their CRM (1 more), adds a transactional service (1 more) — and each vendor's include nests 2-4 lookups inside. Suddenly they're at 14 and SPF is dead, but everything 'looks fine' because the record itself is syntactically valid.
How to fix it: first, count your lookups with an SPF checker that reports the number (ours does). Then flatten: replace include mechanisms with the actual ip4/ip6 ranges they resolve to. Most providers publish their sending IPs; hardcode them. You lose automatic updates when the provider changes IPs (monitor for this), but you gain a record that actually evaluates. Alternatively, use an SPF flattening service that auto-updates — but understand what it's doing before trusting it.
-all vs ~all: the qualifier decision
The internet is split on this, and both camps have a point. -all (hard fail) tells receivers to reject unauthorized mail outright. It's the correct end state — maximum protection. ~all (softfail) tells receivers to accept but flag unauthorized mail. It's the safe starting state.
Start with ~all. Here's why: during setup, you will forget a sender. Marketing uses a new tool, HR sends from a new system, someone configures a WordPress plugin that sends notifications. With ~all, those emails land in spam or get flagged — annoying but recoverable. With -all, they vanish silently, and you find out when a customer complains about a missing invoice.
Move to -all after 2-4 weeks of DMARC aggregate reports showing zero legitimate failures. The reports (rua=) tell you exactly which IPs are sending as you and whether they pass — that's your evidence that -all is safe. This is the same phased approach as DMARC p=none to p=reject, and for the same reason: email infrastructure has more senders than anyone remembers.
One more qualifier note: ?all (neutral) is effectively 'I published SPF but have no opinion.' It satisfies 'has an SPF record' checkers while providing zero protection. If you see ?all in the wild, treat it as a misconfiguration.
Common SPF errors in the wild
Multiple SPF records: DNS allows only one TXT record starting with v=spf1 per domain. Publish two and receivers get permerror — they can't know which to trust. This happens when someone adds a new record instead of editing the existing one. Always modify, never add a second.
Exceeding the lookup limit (covered above) — the most common silent failure. Syntactically valid, functionally dead.
Forgetting the record entirely on subdomains that send mail. SPF is per-domain: mail.yourdomain.com needs its own record if it sends. Attackers know this — unprotected subdomains are a favorite spoofing target.
Using ptr mechanism: it's slow, unreliable, and most receivers deprioritize it. RFC 7208 discourages it. If you see ptr in an SPF record, remove it.
Non-sending domains without v=spf1 -all: if a domain never sends mail (parking pages, redirect domains), publish v=spf1 -all explicitly. This tells the world 'nobody is authorized' — without it, attackers spoof these forgotten domains freely because nobody bothered to protect them.
Syntax errors: missing v=spf1 prefix, spaces in the wrong places, unquoted special characters. SPF is whitespace-sensitive in ways that surprise people. Always validate after editing.
SPF and DMARC alignment
SPF alone doesn't satisfy DMARC — it needs alignment. DMARC requires that the domain in the envelope sender (what SPF checks) matches the domain in the visible From header. If your envelope says [email protected] but your From says [email protected], SPF might pass but DMARC fails the alignment check.
This is why SaaS email tools offer 'custom return-path' or 'custom DKIM domain' setup: it aligns the envelope with your domain so SPF contributes to DMARC. Without it, you're relying entirely on DKIM for DMARC — which works, but you've lost your redundancy.
When you run a DMARC report, check the SPF alignment column specifically. 'SPF pass, alignment fail' means your record works but your sender configuration doesn't — fix it at the provider, not in DNS.
How AIClicks helps
Free DMARC checker
Tests your SPF record live: syntax, lookup count, mechanisms, and qualifier — plus DKIM, DMARC, BIMI, and MTA-STS in the same scan.
SPF explainer
Quick reference for SPF record format and the lookup limit.
Full site scan
SPF is one module of the complete email security assessment.
FAQ
How do I check my SPF record?
Run our free email checker — it validates SPF syntax, counts DNS lookups against the 10-limit, lists every mechanism, and flags errors. Or manually: dig TXT yourdomain.com and look for the v=spf1 record.
What happens if I exceed 10 DNS lookups?
SPF returns permerror (permanent error), which receivers treat as 'no valid SPF.' Your policy is effectively dead — even though the record looks correct. Flatten includes into ip4/ip6 ranges to fix it.
Should I use -all or ~all?
Start with ~all (softfail) during setup so forgotten senders get flagged, not silently dropped. Move to -all (hard fail) after 2-4 weeks of DMARC reports confirm all legitimate mail authenticates.
Can I have multiple SPF records?
No — exactly one TXT record starting with v=spf1 per domain. Two records cause permerror. Always edit the existing record; never add a second.
Does SPF stop spoofing by itself?
No. SPF checks the envelope sender, not the visible From header. An attacker can pass SPF with their own domain while displaying yours. DMARC alignment closes this gap — that's why you need all three.
My domain doesn't send email. Do I need SPF?
Yes — publish v=spf1 -all. This explicitly authorizes nobody, preventing attackers from spoofing your non-sending domains. Unprotected parked domains are a favorite spoofing target.
The bottom line
SPF is simple in concept and treacherous in practice. The syntax takes 10 minutes to learn; the lookup limit takes down domains that have had SPF 'working' for years. Count your lookups, start with ~all, monitor with DMARC reports, and tighten to -all when the data says it's safe.
And remember: SPF is one leg of a three-legged stool. It needs DKIM for forwarding resilience and DMARC for From-header alignment. Get all three right and exact-domain spoofing stops working against you.
Is your SPF record actually working?
Free check: syntax, lookup count, mechanisms, and errors — plus DKIM, DMARC, BIMI, MTA-STS.
Check my SPF freeMore from the blog
Why Your Website Gets Zero AI Citations (And How to Fix It)
ChatGPT, Perplexity, and Google AI Overviews cite a tiny fraction of the web. Here's how AI citation actually works, why most sites are invisible, and a 30-day plan to change that.
DMARC p=reject: The 10-Minute Setup That Stops Email Spoofing
Anyone can send email 'from' your domain today. DMARC at p=reject fixes that. Here's the exact setup — SPF, DKIM, and DMARC in the right order, without breaking legitimate mail.
Security Headers: The 6 That Matter Most (And How to Fix Them)
Six HTTP response headers block entire classes of attacks — clickjacking, XSS, SSL stripping, MIME sniffing — with a few lines of server config. Here's what each one does, with copy-paste snippets for Nginx and Apache.
How to Write an llms.txt File (Free Generator + Examples)
llms.txt is a markdown file at your domain root that tells AI systems what your site is and which pages matter. Here's the exact spec, a complete annotated example, the five mistakes that make most llms.txt files useless, and a free generator.
What Is BIMI? How Brand Logos in Email Work (And How to Get Yours)
BIMI puts your logo next to your emails in Gmail, Yahoo, and Apple Mail — but only if your DMARC is enforced. Here's what BIMI requires, what it costs, and whether it's worth it.
