Back to blog
SPF

SPF Flattening: When It Helps and Hurts

Flattening buys lookup headroom by inlining IPs. It also freezes your record the day a vendor rotates their sending pool.

ZeroHook
ZeroHook Team
Security Analysts
Nov 7, 2026~3 min read
SPF Flattening: When It Helps and Hurts
Someone added a fourth ESP include on a Friday, permerror showed lookup eleven by Monday, and the flattening vendor's auto-expanded TXT still listed an IP range the payroll provider had retired six weeks earlier.

Why SPF Hits a Wall at Ten Lookups

Mailbox providers enforce a hard cap of ten DNS lookups per SPF check (RFC 7208). Each `include:`, `a`, `mx`, `ptr`, `exists:`, and `redirect=` counts, including lookups inside nested includes. Google Workspace plus Microsoft 365 plus two ESPs on one apex can cross ten while the TXT still looks tidy.

What flattening tries to do

Flattening means swapping `include:vendor.com` for the literal IPv4 and IPv6 ranges that vendor publishes today, sometimes kept current by a SaaS that rewrites your SPF TXT on a schedule. Lookup count drops because `ip4:` and `ip6:` mechanisms do not recurse the same way includes do.

Warning

Flattened IPs go stale. ESPs rotate pools. A record that worked in January can authorize the wrong netblock or miss legitimate sends in March.
“Flattening is a loan against future vendor IP changes. Someone has to pay it back.”

When Flattening Helps

Look, flattening is defensible when you truly need many authorized senders on one apex, you can't move senders to subdomains, and you've got automation that refreshes IP lists at least weekly from vendor documentation.

Good fit signals

  • Validators report 9 to 10 lookups with one small include left to add
  • Vendors publish stable SPF include targets with documented IP ranges
  • You monitor DNS and have rollback if a flattening job writes bad TXT

Pro tip

Subdomain delegation beats flattening for many teams. Send marketing from `news.example.com` with its own SPF and DKIM instead of stacking four includes on `example.com`.

When Flattening Hurts

Failure modes we see in audits

  • Flattening service writes a TXT longer than some DNS UI limits, truncating mid-mechanism
  • Stale `ip4:` entries after ESP migration while old includes were removed from the record text but IPs stayed
  • Two SPF records after a flattening tool and a human both edit TXT
  • Over-broad `/8` style ranges pasted to "make it work," which weakens authorization more than a tight include

Warning

Flattening doesn't replace DMARC or fix misaligned From: headers. It only changes how you stay under lookup limits.

Safer Paths Before You Flatten

1

Inventory senders. Remove dead includes left from churned vendors.

2

Run lookup count at zerohook.org/spf-checker. Know your number before you add anything.

3

Move bulk mail to a dedicated subdomain with its own SPF and DKIM keys.

4

Use `redirect=` on a subdomain to centralize policy if your DNS provider supports it cleanly.

5

If you must flatten, document which service owns TXT writes and alert when it changes records.

6

Re-count lookups after every flattening job; permerror is silent until Gmail rejects mail.

Pro Tip
Try these before a flattening SaaS owns your apex TXT without a rollback plan. Re-count lookups after the last step even when nothing looks broken.

Frequently Asked Questions

Key takeaways

1

Ten lookups is a hard receiver limit; permerror breaks auth even when dig looks fine.

2

Flattening trades lookup headroom for operational risk when IPs rotate.

3

Subdomains and redirects often beat flattening on apex domains with many ESPs.

4

Never run two SPF TXT records after a tool edits DNS.

5

Count lookups after every DNS change, not only at initial setup.

Count mechanisms and catch permerror before you flatten blindly at zerohook.org/spf-checker.

Share this analysis

Help others discover this content

Fix DNS before the next audit
Provider-specific copy-paste fixes for Cloudflare, Route53, GoDaddy, and more.
Start free scan

More from our blog