Introduction
If you’re managing your domain’s email authentication, you probably know about SPF (Sender Policy Framework) — the protocol that tells mail servers which IPs are allowed to send emails on your behalf.
But what you might not know is that your SPF record can fail silently if it exceeds a hidden limit: the 10 DNS lookup rule. This is where SPF flattening comes in.
In this post, you’ll learn:
- ✅ What SPF flattening is
- 🚫 Why excessive DNS lookups break SPF
- 🔧 How to fix it using flattening techniques
- 🛠️ Tools to automate SPF flattening
What Is SPF Flattening?
SPF flattening is the process of resolving all “include:” mechanisms and nested DNS lookups in your SPF record into a single list of IP addresses, to reduce the number of DNS queries.
Instead of this:
v=spf1 include:_spf.google.com include:sendgrid.net ~all
You get this:
v=spf1 ip4:64.233.160.0/19 ip4:149.72.0.0/16 ~all
The flattened version avoids multiple DNS lookups, helping you stay under the limit and avoid SPF failures.
Why Does SPF Have a DNS Lookup Limit?
The SPF specification (RFC 7208) states:
- Only 10 DNS lookups are allowed per SPF check.
- This includes
include:,a,mx,ptr, andredirect=. - Exceeding this causes a “permerror”, and the SPF check fails.
This happens silently and can hurt your email deliverability without warning.
Common Causes of Too Many SPF Lookups
You’re at risk of breaking SPF if:
- You use multiple email platforms (e.g., Gmail, Mailchimp, Sendinblue, Outlook).
- Each provider uses its own nested
include:statements. - You don’t optimize or consolidate your SPF record.
Example SPF record:
v=spf1 include:_spf.google.com include:spf.mailjet.com include:servers.mcsv.net include:spf.protection.outlook.com ~all
This may result in 20+ DNS lookups due to nesting — violating the 10-lookup rule.
How SPF Flattening Fixes This
Flattening your SPF record:
- Resolves all
include:domains into IP ranges - Removes nested DNS lookups
- Keeps SPF queries under the limit
- Improves performance and reliability
Important: IPs from email providers may change — which means you must monitor flattened SPF records regularly.
How to Flatten Your SPF Record (Step-by-Step)
✅ Option 1: Manually Flatten SPF
- Check each
include:usingdig,nslookup, or SPF tools. - Replace includes with IP ranges from those records.
- Merge all IPs into a single SPF line.
- Keep total characters under 255 for TXT records.
⚠️ Warning: You’ll need to update manually whenever your provider’s IPs change.
✅ Option 2: Use SPF Flattening Tools
Pros and Cons of SPF Flattening
| Pros | Cons |
|---|---|
| Reduces DNS lookups | Flattened IPs can become outdated |
| Prevents SPF permerror | Manual flattening requires monitoring |
| Improves email deliverability | Tools may cost money |
Tips to Keep SPF Clean and Effective
- 🔄 Review SPF records quarterly
- 🧹 Remove unused or old providers
- 🔍 Use
~allor-allto define fail behavior - 📊 Monitor DMARC and SPF reports for failures
- 🛠️ Use automated flattening services for less maintenance
Final Thoughts
SPF flattening is critical to avoid email delivery failures caused by DNS lookup limits. If your SPF record exceeds 10 lookups, SPF validation will break — possibly without any warning.
To ensure reliable authentication and deliverability, flatten your SPF record using the tools mentioned above, and monitor it regularly for changes. It’s one of the smartest things you can do to protect your domain and boost email performance.

