What is SPF flattening?
Replacing the includes in an SPF record with the IP ranges they resolve to, to stay under the 10 lookup limit.
How it works in practice
Flattening trades lookups for length and freshness. The record gets longer, sometimes beyond what fits in one DNS response, so it has to be split into sub-records, and it only stays correct while the providers' IPs stay the same. It works best for senders whose IPs rarely change and badly for large providers that rotate addresses.
What flattening does
Flattening replaces include terms with the ip4 and ip6 addresses those includes resolve to. Since IP terms cost no lookups, a record that was over the limit of 10 can fall back under it. Because one TXT string is limited to 255 characters and a DNS answer to a limited size, very large flattened records have to be split across several included sub-records.
Why it needs maintenance
A flattened record is a snapshot of the provider's addresses at one moment. When the provider adds or moves servers, an include would follow the change on its own, but your copy does not, so mail from the new addresses fails SPF with no error on your side. A flattened record must be regenerated on a schedule, or by a service that watches the providers for you.
Alternatives to try first
Remove senders you no longer use, move bulk senders to a subdomain with its own record, and prefer providers that publish one short include. These keep the record readable and do not go stale. Flatten only the includes that are stable and that you cannot avoid.
The common mistake
Publishing a flattened record once and never refreshing it.
Frequently asked questions
Is SPF flattening safe?
It is safe while the flattened addresses are kept current. The risk is silent failure when a provider changes its IP ranges and your record does not.
Can every include be flattened?
No. exists and ptr terms cannot be flattened, and some providers use ranges that change often enough that flattening them by hand is not practical.
How often should a flattened record be refreshed?
As often as the providers change their addresses, which can be daily for large ones. In practice this means automating it or avoiding flattening for those providers.
Check it yourself
Related terms
Not sure whether this is what's hurting your inbox placement? A free deliverability review finds the real cause.
How we help: Consulting · Private infrastructure · Managed mailboxes · Monthly support