Skip to content

SPF 10-lookup limit — diagnosing and fixing it on cPanel domains

SPF caps at 10 DNS lookups per evaluation. A domain with three SaaS senders blows through it. Here is how to count and how to flatten without losing legitimate senders.

A customer’s SPF passes validation in mxtoolbox but mail to Google still goes to spam with softfail. The SPF record looks reasonable: v=spf1 include:_spf.google.com include:spf.protection.outlook.com include:mailgun.org include:_spf.mlsend.com ~all. Each include: looks innocent. The total DNS lookup count, when you actually expand each include, is 17. SPF caps at 10. Anything above produces permerror per the spec, and receivers treat permerror as either fail or softfail depending on the receiver.

What’s happening

SPF (RFC 7208) lets you include: another domain’s SPF policy. Each include: is itself a DNS lookup, and the included policy can chain to more includes. The total count of all DNS lookups during evaluation is capped at 10. Common SPF chains:

  • _spf.google.com — 4 lookups (it includes 4 sub-policies internally).
  • spf.protection.outlook.com — 1 lookup.
  • mailgun.org — 2 lookups.
  • _spf.mlsend.com (MailerLite) — 2 lookups.

A domain that includes Google + Outlook + Mailgun + MailerLite is at 9 plus the initial query, which is 10 if you’re lucky. Add one more SaaS and you’ve exceeded the limit. The evaluation hits permerror, and the spec says senders SHOULD treat this as if no SPF were published — but many receivers treat permerror as fail.

The fix is not to include more — it’s to flatten. Replace include: with the IP ranges the included domain returns. Trade DNS lookups for record size (records can be up to 4 KB).

How to verify

Count lookups with a validation tool:

curl -s "https://api.mxtoolbox.com/api/v1/lookup/spf/example.com" 2>/dev/null | grep -i lookups

Or manually walk every include::

dig +short TXT example.com
# pick the v=spf1 record, follow each include:
dig +short TXT _spf.google.com
dig +short TXT _netblocks.google.com
# count each lookup

Confirm the receiver’s interpretation:

grep -i spf /var/log/maillog | tail
# or for received messages, the Authentication-Results header has spf=permerror

spf=permerror in the header is the smoking gun.

What to do

  1. Audit the actual senders. List every service that sends as the domain. Mark the ones the customer actually uses now (not “we used MailerLite three years ago”). Remove inactive include: directives.
  2. Flatten where possible. Replace include:_spf.google.com with the IP ranges Google publishes. Google’s ranges change occasionally — set a cron that re-runs the flatten and updates the record. Several vendors (EasyDMARC, ValiMail, dmarcian) automate this as a paid service.
  3. Consolidate same-vendor senders. If you send through both Mailgun’s US and EU regions, both go through mailgun.org — one include covers both.
  4. Use the manual ip4: directive for fixed senders. A self-hosted Mailcow or Postal instance with a known IP doesn’t need include: — just ip4:192.0.2.10.
  5. Subdomain isolation for marketing email. Move transactional and marketing senders to separate subdomains: mg.example.com for marketing, tx.example.com for transactional, example.com apex for human mail. Each subdomain has its own SPF, well under the 10-lookup limit.
  6. Verify the final record is under 10 lookups with the tool of choice. Re-check after every change.

For DNS provided by cPanel, the SPF lives in the zone editor. Publishing a flattened SPF with literal IPs means re-checking when the IPs change. The trade-off of flatten-and-monitor versus include-and-stay-current is one each operator picks based on tolerance for occasional rebuilds.

Stack Harbor audits and flattens SPF as part of mail-deliverability work in migration solutions.