An SPF record listing ten sending providers looks thorough and harmless. In practice it’s usually the symptom of a domain that has accumulated services, a CRM, a marketing ESP, a support tool, a billing gateway, without ever removing the ones that no longer send mail. Past a certain number of nested lookups, SPF simply stops producing a usable result, and the problem shows up in no mail client: it can only be diagnosed on the receiving server’s side, in headers almost nobody reads.
What the standard actually says
RFC 7208, which defines SPF, caps the check at ten “expensive” DNS lookups: every include, a, mx, ptr and exists mechanism spends one unit of that budget, and every include nested inside another include counts too. The all mechanism and the ip4/ip6 qualifiers cost nothing, since they trigger no further DNS resolution. Past the tenth lookup, the receiving server must return a permerror result: not a clean failure (fail), not a pass, but a configuration error that prevents any reliable evaluation of the record.
How a permerror gets handled then depends entirely on the recipient’s policy. Some treat it as a soft failure and let the message through with a degraded reputation score; others, especially when the domain runs DMARC with a strict policy, treat it as a missing SPF alignment and apply that policy’s reject or quarantine action directly.
Why domains cross the limit without noticing
The overrun is almost always gradual. A single include looks harmless, but every provider adds its own sub-inclusions to spread its sending ranges across regions or infrastructures. A marketing ESP declaring three or four internal include entries can, on its own, burn through half the available budget. Add a CRM, a support tool, a billing gateway and a transactional sending service, each with its own inclusion chain, and the limit of ten is exceeded before it feels like you’ve added many services at all.
| Mechanism | DNS lookup cost | Common trap |
|---|---|---|
include:example.com | 1 per level, plus nested inclusions | A single ESP include can hide three or four more |
a | 1 | Often pointless if the domain doesn’t send from its own mail server |
mx | 1, plus one lookup per returned MX record | Expensive when several MX records exist for redundancy |
ptr | 1, plus one lookup per PTR record | Discouraged by the standard itself for several revisions now |
ip4 / ip6 | 0 | None: the only way to get under the limit without losing coverage |
Diagnosing a record that’s close to or over the limit
Diagnosis happens in two steps: read the raw record, then unroll every include to count the lookups actually performed, nested ones included. Most online tools (MXToolbox, dmarcian’s SPF Surveyor) do this automatically, but a manual check still helps pinpoint exactly which link tips the total over.
# Read the domain's SPF record
dig txt example.com +short | grep spf1
# Unroll one particular include to see what it contains
dig txt _spf.esp-provider.com +short
# Count top-level consuming mechanisms on the root record
dig txt example.com +short | grep -oE '(include|a|mx|ptr|exists):[^ ]*' | wc -l
That last count only reflects the first level: an include pointing to a record that itself contains three more include entries adds three lookups, not one. That’s exactly what manual checks tend to miss, and why a “five-line” record can still exceed the limit even though it looks reasonable at a glance.
An SPF record that goes past ten nested DNS lookups doesn’t fail cleanly: it flips into a permanent error, a state the standard treats very differently from a plain rejection.
Fixing it: trim first, flatten only as a last resort
The most commonly cited fix is to “flatten” SPF: replace every include with the static list of IP addresses it resolves to, bringing the DNS lookup cost down to zero. It works in the short term, but it creates a silent debt: if the provider changes its sending ranges without notice, which happens regularly, the flattened record goes stale and legitimate sends start failing with no alert to anyone. Flattening is only defensible when paired with automated monitoring that periodically re-compares the provider’s published IPs against the ones frozen into the record.
Before flattening, it’s better to reduce the actual number of services sending on behalf of the primary domain. Three levers, in order of priority:
- Remove
includeentries for services that haven’t actually sent mail in months, which happens more often than expected after a marketing or support tool switch. - Move transactional and marketing sends to dedicated subdomains (for example
mail.example.comandnews.example.com), each with its own SPF record limited to its own services: the ten-lookup budget is calculated per evaluated domain, not for the whole organization. - Drop
mxandptrmechanisms when they don’t match any real usage: many records keep them out of habit even though no mail server sends directly from the domain’s MX hosts anymore.
What DMARC changes in the equation
A domain running DMARC with a p=reject or p=quarantine policy has zero tolerance for an SPF permerror: alignment fails, and DMARC falls back on the DKIM evaluation to save the message, if DKIM is correctly configured and aligned. A domain that relies on SPF alone for DMARC alignment, with no reliable DKIM backup, turns a simple ten-lookup overrun into a direct cause of mass rejection. That’s one more reason to treat SPF and DKIM as two genuinely independent mechanisms rather than a box to tick once and forget.
Key takeaways
The ten-DNS-lookup threshold set by RFC 7208 isn’t a best-practice suggestion, it’s a technical limit whose breach produces a permanent error with unpredictable consequences depending on the recipient’s policy. Diagnosis means unrolling every nested include, not just counting the lines in the root record. A durable fix comes from reducing the actual number of declared services and segmenting by subdomain, with full flattening left as a last resort that needs continuous monitoring.
On nearly every deliverability audit I run, the client’s SPF record crosses the limit as soon as you bother unrolling the nested inclusions, and nobody had noticed because the symptom looks like any other reputation problem. I always start an audit with that calculation, before even looking at DKIM or DMARC: it’s quick to check, and it saves time chasing a complicated explanation for a problem that comes down to one line of configuration. — Simon Janvier
Further reading: RFC 7208, section 4.6.4, which defines the ten-DNS-lookup limit.
