Blog · · 6 min read
SPF's ten-lookup limit, and how to stay under it
By Y Naga Vamsi, creator of Mailtruss.
On this page
A common way for SPF to break is invisible: the record is valid, every include points at a real service, and one day SPF starts failing for everyone. The usual cause is the ten-lookup limit, which you hit by adding one more email service.
What the limit is
RFC 7208 section 4.6.4 says that evaluating an SPF record may cause at most ten DNS-querying terms. Past that, the receiver must return a permanent error (permerror), and SPF does not pass. The count includes terms inside every record you include.
What counts
include:,a,mx,ptr,exists:andredirect=each count as one lookup.- An include counts, and so does every counted term in the record it points at. One
include:of a large provider can cost four or five. ip4:,ip6:andallcost nothing, because they need no DNS query.
The standard also tells receivers to stop after two "void" lookups, which are lookups that return nothing, so an include pointing at a name with no SPF record is itself a problem.
Count yours
Doing this by hand means opening each include and each nested include. The domain checker follows them for you and shows how many of the ten you use, along with other common SPF mistakes such as two records on one name or a record that ends in +all.
Getting under the limit
- Remove what you no longer use. Old marketing tools and abandoned services stay in SPF records for years. This is the safest fix and often enough.
- Send each service from its own subdomain.
mail.yourdomain.comandnews.yourdomain.comeach get their own SPF record with their own ten lookups. DMARC still aligns, because subdomains share the organisational domain. - Use `ip4:` and `ip6:` for services whose addresses never change , such as your own servers.
- Be careful with flattening. Replacing an include with the list of IP addresses it resolves to removes the lookups, but providers change their addresses. A flattened record that is not regenerated automatically goes stale and starts failing mail.
Other things worth checking while you are there
- Exactly one SPF record per name. Two make SPF fail, and merging them into one is the fix.
- End with
~allor-all.?allprotects nothing, and+allallows anyone to send as you. - Avoid
ptr. RFC 7208 says it should not be used: it is slow and unreliable. - SPF is one of three checks. Read how SPF, DKIM and DMARC fit together before tightening anything.
Keep reading
- 6 min readSwitching email providers without losing mail: a checklistA step-by-step checklist for moving to a new email API or SMTP service: inventory, DNS and SPF, test sends, a gradual switch, suppressions, webhooks and what to keep running.
- 6 min readHow to read an email bounce: what 550 5.1.1 and 5.7.1 meanA bounce carries two codes and a sentence. Here is how to read them: the reply code, the enhanced status code, the digits that say retry or not, and the codes you will see most.