SPF 10-Lookup Limit & Flattening Guide

The SPF 10-lookup limit is the rule in RFC 7208 §4.6.4 that a receiver evaluating an SPF record may perform at most 10 DNS lookups — count an 11th, and the receiver must return permerror, a permanent error, and SPF fails. It is a small number, and records reach it quietly: every SaaS sender you add is another include, and every include hides its own includes. This guide explains the limit, why records grow past it, how to read the lookup budget, the three fixes in order, what void lookups are, and the trade-off in flattening — then shows you how to count your own record with the SPF Lookup Counter & Flattener.

The 10-DNS-lookup limit in one sentence

SPF — Sender Policy Framework, RFC 7208 — is a TXT record that starts with v=spf1 and lists the servers allowed to send mail for a domain. When a receiver checks a message, it evaluates the record term by term, and some terms cost a DNS lookup. Section 4.6.4 of the RFC sets the budget: one evaluation may cause at most 10 DNS lookups, and a receiver that counts more must return permerror — a permanent error — and SPF fails. The same section caps void lookups — lookups that return an empty answer or NXDOMAIN — at 2. The limit is not a suggestion and not a soft cap: it is the number at which a conforming receiver stops evaluating and fails the check.

Why 10? Because SPF evaluation is recursive — an include pulls in another record, which pulls in more includes — and without a cap, a hostile or careless record could make a receiver do unbounded DNS work for every message. The cap keeps that work bounded. But it also means a perfectly legitimate record, assembled by adding one SaaS sender at a time over years, can cross the line with no warning and no error message to the sender: mail just starts failing at the strict receivers, while the lenient ones keep accepting it, which makes the failure look intermittent and hard to diagnose.

Why records grow past 10 without anyone noticing

Nobody writes a 12-lookup record on purpose. It grows. Marketing adds SendGrid, support adds Zendesk, sales adds Salesforce, HR adds a survey tool, and each addition is one more include: in the record. Each include is a doorway, not a destination: Google's _spf.google.com alone expands to three more includes — _netblocks.google.com, _netblocks2.google.com and _netblocks3.google.com — before it reaches a single IP address, and Microsoft's spf.protection.outlook.com chains through spfa and spfb. So a record that looks short — five includes and an ~all — can cost 12 lookups, because the cost lives in the tree, not in the line.

The other way records grow is by never shrinking. The provider you stopped using three years ago is still in the record, its include still costing a lookup — and if that provider retired its SPF record, the lookup is now a void lookup as well, so it hurts twice. Nobody owns the record, nobody reviews it, and the senders in it are the senders of three reorganisations ago. The fix starts with reading the record the way a receiver does — term by term, with the tree expanded — which is what the SPF Lookup Counter & Flattener does: enter a domain and it shows the expansion tree, the cost of every term, and the flattened record ready to paste back into DNS.SPF Lookup Counter result for the heavy demo record: Score 49/100 — Poor, permerror banner, 12 of 10 DNS lookups, and the flattened record

Reading the lookup budget: which terms cost a lookup

The budget is simple once you know the price list. These terms cost one DNS lookup each: include:, a, mx, ptr, exists: and the redirect= modifier. These cost nothing: ip4:, ip6: and the final all. A record made only of ip4 and ip6 terms costs zero lookups, no matter how long it is — which is exactly why flattening works. Two details trip people up. First, mx costs exactly one lookup for the MX query itself; the address lookups for the MX hosts are not counted against the 10, though they still have to succeed for the mechanism to match. Second, a bare a or mx with no domain means the publishing domain itself, so it still costs one.

Then there is the second budget, the one people forget: void lookups. A lookup that returns an empty answer or NXDOMAIN is void, and more than 2 void lookups in one evaluation is also permerror — even if the total is well under 10. A dead include is therefore the worst term in a record: it costs one of your 10 lookups and one of your 2 voids, and it contributes nothing, because the provider it names no longer publishes an SPF record. Three dead includes and the record fails on voids alone, before the lookup count even matters.

The three fixes, in order

Fix one: drop senders you no longer use. It is free, it is immediate, and it is the fix most records need first. Audit the record against who actually sends mail for the domain today — the marketing platform you left, the survey tool from a campaign two years ago, the helpdesk you replaced — and delete their includes. Every include you remove takes its whole subtree with it: removing one include that expands to three more saves four lookups, not one. If that alone brings the record under 10, stop here; a short honest record beats a clever one.

Fix two: flatten what remains. Replace each include with the concrete ip4 and ip6 addresses it resolves to, so the record costs zero lookups. The SPF Lookup Counter & Flattener builds that record for you — paste a domain, read the tree, copy the flattened record. Fix three, for records that stay big even after flattening: split senders across subdomains, one record per sender class — marketing mail from mail.example.com, transactional mail from send.example.com — so each record stays small and each team's changes stop breaking the others'. Use fix three when the sender list itself is the problem, not the includes.

Void lookups, macros and redirect — the details that bite

Void lookups deserve their own section because they fail records that look fine. An include whose target answers TXT but has no v=spf1 record — a verification string, a DMARC record, a typo in the hostname — is not void, but it still breaks the evaluation with permerror, because there is no SPF record to evaluate. An include whose target does not exist at all, or answers nothing, is void. And an a term for a host with no A or AAAA record is void too. The distinction matters for diagnosis — the tool's tree marks each one — but the remedy is the same in every case: remove the dead term or fix the hostname.

Two more mechanisms, briefly. Macros — %{...} placeholders in a term — are evaluated by the receiver per connection, so this tool counts them (an exists: with a macro still costs one lookup) but never expands them; their target cannot be known in advance. And redirect= hands the whole evaluation to another domain's record: it costs one lookup itself, the target's record is evaluated in full, and if the target has no SPF record the result is permerror. A redirect is a good way to share one record across many domains — and a good way to break them all at once when the target changes.

The flattening trade-off — and what the tool cannot see

Flattening trades one failure mode for another. It removes the lookup-limit failure completely — a flattened record costs zero lookups — and replaces it with staleness: the flattened IPs are a snapshot of the day you flattened, and if a provider changes its sending IPs, your record silently goes out of date and mail starts failing. The trade is worth making, but only with a schedule: re-flatten monthly, and every time you add or remove a sender. Watch the size too: a flattened record over 255 characters must be published as a multi-string TXT record, and over about 450 characters UDP answers risk truncation — both are flagged by the tool, and both are reasons to drop senders before you flatten, not after.

And the tool's limits are the limits of the record. It cannot see your actual sending IPs — only the ones the record names — so it cannot tell you whether a sender really sends from the addresses its include resolves to. It cannot see DMARC alignment, which is a separate check on the From domain. It cannot know whether a provider changed its IPs since you flattened, or whether a receiver counts a borderline case differently — mx host address lookups and exists: evaluation are the known margins where receivers differ. What it can do is show you the exact count, the exact tree, and the exact flattened record, so the decision is made on numbers instead of guesses. Count yours with the SPF Lookup Counter & Flattener.

Sources

Frequently asked questions

My record has 12 lookups — why does some mail still get through?

Because not every receiver enforces the limit the same way. Strict receivers return permerror and fail SPF, exactly as RFC 7208 requires; lenient ones evaluate past the limit, or serve a cached copy of an older, shorter record. Deliverability that depends on leniency is already broken in practice: the next receiver in the chain, or the same receiver after its cache expires, can fail the same message. Fix the record — do not rely on receivers that let it through.

Is flattening safe? Won't the IPs go stale?

Flattening swaps one failure mode for another: it removes lookup-limit failures and adds staleness failures. It is safe when you re-flatten on a schedule — monthly is the usual cadence — and every time you add or remove a sender, and when the flattened record stays small enough to fit in DNS. It is not safe as set-and-forget. If your senders change IPs often, or you cannot commit to regular re-flattening, remove unused senders and split senders across subdomains instead.

Why does this checker count my includes differently from my provider's checker?

Receivers differ slightly in how they count borderline cases — the known differences are mx host address lookups and exists: evaluation — and some checkers do not count void lookups at all, or stop counting at the first error. This checker follows RFC 7208 §4.6.4 literally and shows the per-term tree, so you can see exactly where each count comes from and compare. A record at 9 or 10 is one include away from failing either way, so flatten it before arguing about the last lookup.