Skip to main content
BytesProbe
Probe. Diagnose. Secure.

SPF and the ten DNS lookup limit

Why SPF stops at ten DNS lookups, how to count yours, and the three ways to get back under the limit without dropping a sender.

SPF has a hard ceiling written into the standard: a receiving mail server may perform at most ten DNS lookups while evaluating your record. Go over it and the check does not simply ignore the extra entries — it fails. RFC 7208 calls for a permerror result, and a permerror is treated as an SPF failure by most receivers. For a domain running DMARC at enforcement, that can mean your own mail being rejected.

The limit catches people out because it is easy to exceed by doing nothing wrong. You add a CRM, a helpdesk, an invoicing tool and a marketing platform, each with its own include:, and one day a vendor expands their own record and pushes you over a line you never knew you were near.

What counts as a lookup

Only some mechanisms cost a lookup. These do, every time they are evaluated:

  • include: — and everything inside the included record counts too
  • a and mx — mx costs one lookup for the MX set, then one more for each host it returns
  • ptr — deprecated, slow, and best removed entirely
  • exists:
  • redirect=

These cost nothing, because they are answered from the record itself or from the connection:

  • ip4: and ip6:
  • all
  • Qualifiers such as +, ~ and -

That asymmetry is the key to fixing an over-limit record: an address range costs nothing, a hostname costs something.

The limit is recursive

This is the part that surprises people. The ten is a total for the whole evaluation, not per record. If your record contains three include: mechanisms and each of those records contains three of their own, you are at twelve before counting anything else. You cannot see the real total by looking at your own TXT record; you have to walk the tree.

There is a second, separate limit worth knowing: at most two void lookups, meaning lookups that return NXDOMAIN or no answer. A stale include: pointing at a vendor you stopped using can trip that on its own.

Counting yours

Run your domain through the SPF record checker. It walks the whole tree, counts the lookups the way a receiver would, and shows which mechanism contributed what. You are looking for two things: the total, and which single include: is responsible for most of it.

Do this before you are in trouble. A record at eight or nine is not failing, but it has no room left, and the next vendor who expands their own record will push you over without telling you.

Three ways back under the limit

1. Remove what you are not using

Start here, because it is free. Most over-limit records contain at least one include: for a service that was trialled and abandoned, or a ptr mechanism that should have gone years ago. Work through every mechanism and ask: does mail actually leave through this path today? If you cannot name the system, it is a candidate for removal.

Be careful with anything used rarely but genuinely — an annual billing run, a password reset system that fires only on demand. Those paths send little mail and are easy to forget, and their failure is quiet.

2. Replace an include with its addresses

An include: costs at least one lookup and often several. The addresses it ultimately authorises cost nothing if you write them as ip4: and ip6: ranges directly.

This trades maintenance for headroom, and the trade is only safe when the sender's addresses are stable and published. A vendor who documents a fixed set of ranges and announces changes is a reasonable candidate. A large platform that rotates addresses freely is not: the day they add a range you have not copied, that mail starts failing SPF, and nothing will tell you.

If you do this, write down where each block came from and check it on a schedule. An inlined range with no owner is a future outage.

3. Use subdomains to split the problem

This is the structural fix, and usually the right one. SPF is evaluated against the domain in the envelope sender, so different sending systems can use different subdomains, each with its own record and its own budget of ten.

  • mail.example.com for your corporate mail platform
  • news.example.com for marketing
  • billing.example.com for transactional mail

Each record then holds one or two includes rather than seven. It also contains failures: a misconfiguration in the marketing platform cannot break the SPF evaluation for invoices.

The work is in the sending platforms, which must be configured to use the subdomain as the envelope sender — often called the return path, bounce domain or MAIL FROM domain. The visible From: address can stay as it is, and for DMARC alignment under the relaxed default a subdomain of your organisational domain still aligns.

What not to do

Do not add a second SPF record. A domain must publish exactly one. Two TXT records beginning v=spf1 is itself a permerror, and it is a common accident when two teams each add their own. If you need to authorise another sender, merge it into the existing record.

Do not switch -all to ?all to make failures stop. It does stop them, by telling receivers your record means nothing. You keep the lookup problem and lose the protection.

Do not rely on a flattening service without understanding it. SPF flattening resolves your includes and writes out the addresses automatically. It works, and it moves the maintenance problem to a third party whose failure mode is your mail failing SPF. If you use one, know what happens when it stops updating.

After you change the record

Re-check the count with the SPF checker, then confirm the change has actually reached resolvers before you judge the result — a cached copy of the old record will be served until its TTL expires. The propagation checker shows which resolvers have picked it up.

Then watch your DMARC aggregate reports for a week. They are the only source that tells you whether real receivers are now passing the mail, and they will show any sending path you removed by mistake. The email security checker reports SPF, DKIM and DMARC together, which is the quickest way to confirm the whole picture is still intact.

More in the guides index.