Your SPF record looks right. Every service you use is in it. The syntax checks out. And yet a header from a real message says spf=permerror, and DMARC reports show SPF failing for mail you definitely sent.
Nine times out of ten, the cause is the 10-lookup limit.
The rule
RFC 7208 limits the number of DNS queries a receiver will make while evaluating your SPF record to 10. The mechanisms and modifiers that count are:
includeamxptrexistsredirect
These do not count: ip4, ip6 and all. They are evaluated without a DNS query.
When evaluation would need an eleventh lookup, the receiver stops and returns permerror. A permanent error is not a soft failure. For DMARC purposes, SPF simply did not pass, for every message, from every service.
There is a second, less known limit: no more than two void lookups, meaning queries that return no records at all. An include: pointing to a domain that no longer publishes SPF counts as one.
Why your count is higher than it looks
Includes are counted recursively. Your record might contain four include: terms, but each of those records can contain its own includes, and every one of them costs a lookup.
A realistic example:
v=spf1 include:_spf.google.com include:spf.protection.outlook.com
include:sendgrid.net include:mail.zendesk.com include:_spf.salesforce.com ~all
Five includes, so at least five lookups. What happens next depends on how each provider writes its own record. Some publish a flat list of IP ranges and cost nothing more. Others nest: when this guide was written, sendgrid.net included a further record, and Salesforce's record used an exists check, each costing one more lookup. Add a sixth or seventh service, or one provider with deeper nesting, and the real total passes 10 while the record still looks short.
Providers also restructure their records without telling you, in both directions. Google, for example, replaced nested includes with a flat list of ranges. A record that used 9 lookups last month can use 11 today. That is why a domain sitting at 9 or 10 is fragile even when it currently passes.
The SPF checker follows every include, counts the lookups at each level of the tree, and shows which branch is expensive.
Five fixes, safest first
1. Remove services you no longer use
Look at every include and ask whether that service still sends mail with your domain in the envelope sender. Old marketing platforms, a trial of a help desk, a CRM you migrated away from: they linger in SPF records for years.
This is the only fix with no downside.
2. Remove services that do not need to be there
Many platforms send with their own domain as the envelope sender, even when your address is in the From line. Mail from those platforms is checked against their SPF record, not yours, so including them in yours does nothing except cost lookups.
How to tell: send a message through the service, open the original, and look at the Return-Path header. If it is the platform's domain, not yours, their include does not belong in your record. Their DMARC alignment comes from DKIM, which you set up separately. The header analyzer shows the Return-Path and whether it aligns.
3. Move a sender to a subdomain
SPF records are per domain. If your marketing platform uses news.yourdomain.com as its envelope sender, that subdomain gets its own SPF record with its own budget of 10 lookups, and your root record no longer needs the include.
Most sending platforms support a custom bounce or return-path subdomain. It also keeps marketing reputation separate from your staff mailboxes, which is worth doing anyway.
4. Replace mx and a with IP ranges
If your record uses mx or a and those hosts have stable addresses, write the addresses as ip4: or ip6: terms instead. Each replacement saves a lookup. Note that mx can be expensive in another way: it also requires looking up the address of every MX host.
Only do this for servers you control. If the addresses change, mail from them starts failing SPF.
5. Flatten an include, carefully
"Flattening" means replacing include:provider.example with the IP ranges that record currently resolves to. It works, and it is the fix most likely to hurt you later: when the provider adds a new range, your record does not change, and their new servers fail SPF.
If you flatten, only flatten a provider that publishes its ranges and changes them rarely, and re-check the record on a schedule. Automated "SPF flattening" services exist for exactly this reason. Prefer fixes 1 to 3.
Things that look like fixes but are not
- Splitting into two SPF records. A domain must publish exactly one record starting with
v=spf1. Two records is itself a permanent error. - Switching to
+all. This passes every server on the internet and makes SPF meaningless. Some receivers treat it as a spam signal in its own right. - Removing
~allto "make it shorter". Length is not the problem; lookups are. A record withoutallends with a neutral result.
Rebuild and verify
Once you know which services stay, rebuild the record with the SPF generator. It includes a live lookup count, so you see the real total, nested includes and all, before you publish.
After publishing, wait for the old record's TTL to expire, then:
- Re-run the SPF checker and confirm the count.
- Send a test message from each service and check
spf=passin the headers. - Watch your DMARC aggregate reports for a week. SPF failures from your own sources should disappear.
If you keep the count at 8 or lower, a provider adding one include on their side will not break you overnight. That headroom is worth more than squeezing in one more service.