SPF flattening is the practice of resolving the include: and other lookup-causing mechanisms in an SPF record into literal ip4: and ip6: entries. The goal is to stay within the limit of 10 DNS lookups that SPF evaluators allow.
Why it matters
Each include, a, mx and redirect counts toward the limit. Exceeding it produces a permanent error (permerror), and receivers may treat the message as failing SPF. Flattening removes the lookups, but IP addresses in third-party ranges change without notice, so a static flattened record silently becomes wrong and legitimate mail starts failing. Record length is also limited: a single TXT string holds 255 characters, though several strings can be concatenated, and the whole DNS response should stay small.
Example
Before:
v=spf1 include:_spf.vendor-a.example include:_spf.vendor-b.example ~all
After, with documentation-range addresses:
v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.17 ~all
Use a service or script that re-flattens automatically, or remove unused includes first.
Common mistakes
- Flattening once and never refreshing.
- Not removing vendors you no longer use.
- Forgetting that vendors may offer a dedicated subdomain for sending.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.