SPF “too many DNS lookups” (the limit of 10) and how to fix it

Short answer: an SPF record may trigger at most 10 DNS lookups. Remove services you no longer use, replace lookups with fixed addresses only where safe, and move extra senders to a subdomain.

Reviewed

Symptom

An SPF checker, or a bounce message, says your SPF record has too many DNS lookups, or reports a permerror. Mail that used to arrive starts failing authentication, often right after you added another email service.

Why it happens

An SPF record lists who may send mail for your domain. To check it, the receiving server has to look up some of the entries in DNS. The standard (RFC 7208, section 4.6.4) caps this work: the terms that cause a DNS query may not total more than 10 during one evaluation. If the count goes over, the result is permerror, which means SPF did not pass.

What counts, according to the standard:

Counts toward the 10Does not count
include:ip4:
aip6:
mxall
ptr
exists:
redirect=

The count is a single total for the whole check, so lookups inside an included record add to it. One include: for a mail service can itself contain several more. That is how a record with only five visible include: entries can go over.

The standard also says receivers should stop at two “void” lookups, which are lookups for names that return nothing, for example an include that points to a domain that no longer exists. The standard says exceeding that limit should also give a permerror.

A related mistake gives the same result: more than one SPF record on the same domain is also a permerror (section 4.5), so merge them into one.

Fix

  1. Write down your current record. In a terminal, run dig +short TXT example.com (use your domain), or look at the TXT records at your DNS host. Find the one that starts with v=spf1.
  2. Count the lookups. Count each include:, a, mx, exists: and redirect= in your record. Then look up each include: name the same way and count what is inside it, repeating for any include: you find there. You can also use an online SPF checker that reports the lookup count.
  3. Remove services you no longer use. Old newsletter tools, previous hosts and trial services are the usual culprits. Remove the include: only after you are sure nothing sends through that service.
  4. Replace a and mx with fixed addresses where it is safe. If your own server sends mail from one IP address, ip4:203.0.113.10 costs no lookup. This only works while that address stays the same, so ask your host before you do it. Never replace an include: for a mail service with its addresses unless the service says its addresses are fixed, because services change them.
  5. Move senders to their own subdomain. A service that sends your newsletters can send from news.example.com, with its own SPF record there. Each domain gets its own limit of 10, so the main record becomes shorter. Set it up in the service, and keep the From address in line with the subdomain, so alignment still works (see DMARC for beginners).
  6. Check whether the service needs to be in your root record at all. Some mail services authenticate SPF through their own return-path domain, so they do not have to appear in the SPF record of your main domain. Their setup guide says which. Do not remove an entry on a guess.
  7. Avoid ptr. It counts toward the 10, and the standard says it should not be published (RFC 7208, section 5.5). Remove it if you find it.
  8. Last resort: an SPF flattening service replaces the include: entries with the underlying addresses. It can work, but the addresses change over time, so it only stays correct if the flattened record is updated automatically. A stale flattened record is worse than a record that is too long.

A tidy example for a store that sends only through Google Workspace: v=spf1 include:_spf.google.com ~all. That is the value Google’s documentation gives for Google-only senders.

Check it worked

  • Run the lookup count again. It must be 10 or fewer, and there must be one v=spf1 record on the domain.
  • Send a test email to a mailbox you control and look at the message headers for spf=pass.
  • Allow for DNS caching. A changed record can take up to the TTL (the cache time shown at your DNS host) to be seen everywhere.

SPF is not the only path to a pass. Microsoft’s documentation explains that a message passes DMARC if either the SPF check or the DKIM check passes and is aligned. That is why DKIM is worth having as a second line of defense. Gmail, Yahoo and Outlook.com each ask bulk senders for both, though, so fix SPF too. See Yahoo and Outlook rejecting your emails.

How the plugin helps

Email Health Check & Log for WooCommerce checks your SPF record from the WordPress admin: it reports a missing record, more than one record, a record that authorizes no sender, and whether the record seems to include the mail service your site uses. It does not count DNS lookups, so it will not catch the limit of 10; use the counting steps above or an online SPF checker for that. Get the plugin on WordPress.org.

Check your own domain

Type your domain into the free checker to see whether your SPF, DKIM and DMARC records are in place. Or install the free plugin, which checks the basics from inside your dashboard.