What counts
| Part of the record | Counts towards the limit? |
|---|---|
include, a, mx, ptr, exists, redirect | Yes, one lookup each, also inside included records. |
ip4, ip6, all | No. |
If you include a service that itself includes three other records, you have used four lookups on one line. The SPF lookup counter walks the whole tree and shows where the lookups are spent.
Two more limits
- Void lookups: the standard says the receiver should stop after two lookups that return no answer, for example an
includeto a domain that no longer exists. That gives permerror too. mx: the mechanism must not lead to lookups of more than 10 addresses.
What happens when the record goes over?
The receiver returns permerror instead of pass. The email can then only pass DMARC through DKIM. If the service has no DKIM for your domain, the email fails DMARC, and with p=quarantine or p=reject it ends up in spam or is rejected.
Five ways to get below the limit
- Remove services you no longer use. Old newsletter tools and former email providers are often left behind.
- Remove
aandmxif the servers they point to do not send email. - Replace
includewithip4orip6only for your own servers with fixed addresses. - Move services to subdomains.
news.company.comhas its own SPF record with its own 10 lookups. - Use hosted SPF, where the record is kept below the limit for you and updated when the services change addresses.
What about SPF flattening?
Flattening means replacing include with the IP addresses it points to. That uses no lookups, but the addresses of large services change without notice. Microsoft advises against doing it with include:spf.protection.outlook.com. A flat record must therefore be updated automatically, or it stops being correct.
The SPF flattening tool shows what a flat record would look like for your domain.