SPF Record Too Long? How to Flatten and Fix It

Your SPF record exceeds the 10-lookup limit or the 255-character DNS limit. Learn how SPF flattening works and other strategies to fix an SPF record that's too long.

Email Authentication

Your SPF record breaks when it gets too large. There are two limits you can hit: the 10-DNS-lookup limit (which causes authentication failures) and the 255-character TXT record limit (which causes DNS errors). Both problems become inevitable as you add more email sending services.

SPF flattening is the most common solution — but it comes with trade-offs. Here's how to fix an SPF record that's too long.

The Two Limits

The 10-Lookup Limit

SPF allows a maximum of 10 DNS lookups when evaluating a record. Each include:, a:, mx:, and redirect= mechanism counts as a lookup. When you exceed 10, SPF returns permerror — a permanent error that most receivers treat as a fail.

The problem compounds because includes are nested. include:_spf.google.com alone consumes 3–4 lookups because Google's SPF record contains its own includes.

A typical SPF record with 4–5 services can easily exceed 10 lookups:

v=spf1 include:_spf.google.com include:sendgrid.net include:spf.hubspot.com include:servers.mcsv.net include:spf.brevo.com ~all

This record uses roughly 12–15 lookups — it will fail.

Check your SPF record to see your current lookup count.

The 255-Character TXT Record Limit

DNS TXT records have a 255-character limit per string. While most DNS providers allow you to chain multiple strings into a single record, some don't handle this properly. Long SPF records with many ip4: or ip6: entries can exceed this limit.

What Is SPF Flattening?

SPF flattening replaces include: mechanisms with the IP addresses they resolve to. Instead of telling receivers "check this other domain's SPF record," you list the actual IP addresses directly.

Before Flattening

v=spf1 include:_spf.google.com include:sendgrid.net ~all

This uses 5+ lookups (Google alone uses 3–4).

After Flattening

v=spf1 ip4:209.85.128.0/17 ip4:74.125.0.0/16 ip4:209.85.160.0/19 ip4:167.89.0.0/17 ip4:167.89.64.0/18 ~all

ip4: and ip6: mechanisms don't count against the lookup limit. Flattening can reduce your lookups from 15+ to zero.

How to Flatten Your SPF Record

Manual Flattening

1

Identify all includes

List every include: in your SPF record. Check your ESP documentation for the most current include values.

2

Resolve each include to IPs

For each include, use DNS lookup tools to find the IP addresses and ranges they resolve to. This means following the chain of includes recursively.

3

Replace includes with ip4/ip6 entries

Create a new SPF record using the resolved IP addresses instead of includes.

4

Test the new record

Use our SPF checker to verify the flattened record is valid and covers all your senders.

Warning: Manual flattening is fragile. If any of your ESPs change their IP addresses (which they do regularly), your flattened record becomes outdated and email starts failing.

Automated Flattening Services

SPF flattening tools automate the process:

  1. They monitor the IP addresses behind your includes
  2. When IPs change, they automatically update your SPF record
  3. Some use a CNAME or include: to a managed record that stays current

This is the recommended approach if you need flattening. Manual flattening is a short-term fix that requires constant maintenance.

Monitor your SPF record

Get alerts when your SPF record changes, breaks, or approaches limits. Don't let a broken SPF record silently kill your deliverability.

Alternatives to Flattening

Flattening has downsides — primarily the maintenance burden of keeping IP addresses current. Consider these alternatives first.

Remove Unused Includes

The easiest fix. Audit your SPF record for services you no longer use:

  • Old marketing platforms you've migrated away from
  • Trial accounts for tools you never adopted
  • Services that were set up by someone who left the company

Each removed include saves 1–4 lookups. Many organizations can drop below 10 lookups just by cleaning up.

Use Subdomains

Instead of sending all email from your root domain, split email types across subdomains:

yourdomain.com      → v=spf1 include:_spf.google.com ~all
mail.yourdomain.com → v=spf1 include:sendgrid.net ~all
news.yourdomain.com → v=spf1 include:servers.mcsv.net ~all

Each subdomain gets its own SPF record with its own 10-lookup budget. This also provides reputation isolation — problems with marketing email don't affect your business email.

When using subdomains, each service's From address must use the corresponding subdomain (e.g., [email protected]). Configure your ESP to send from the appropriate subdomain.

Use ip4/ip6 for Static Senders

If you have sending infrastructure with stable, known IP addresses (your own mail server, a dedicated IP from your ESP), list those IPs directly instead of using includes:

v=spf1 ip4:203.0.113.5 include:_spf.google.com ~all

ip4: and ip6: cost zero lookups. This is reliable for IPs you control that don't change, but risky for ESP IPs that rotate.

Combine Services That Share Infrastructure

Some ESPs share SPF includes. If two services use the same parent infrastructure, you may only need one include. Check whether any of your services already cover each other.

SPF Flattening Risks

IP Address Changes

ESPs regularly add, remove, and rotate IP addresses. A flattened record with yesterday's IPs might not cover today's sending infrastructure. This is the primary risk — and why automated flattening tools exist.

Record Maintenance

A flattened SPF record is harder to read and maintain. Instead of recognizable include domains, you have a wall of IP ranges. When troubleshooting, you can't easily tell which IPs belong to which service.

DNS Record Size

A heavily flattened record with many IP ranges can exceed the TXT record size limits. Some flattening tools solve this by using multiple TXT records or macros, but this adds complexity.

Checking Your Record After Changes

After flattening or restructuring your SPF record:

  1. Verify syntax — Use our SPF checker to confirm the record is valid
  2. Count lookups — Ensure you're under the 10-lookup limit
  3. Send test emails — Verify SPF passes by sending to Gmail and checking headers
  4. Monitor for 48 hours — DNS changes take time to propagate fully

Don't make multiple changes at once. Fix one thing, verify it works, then move on.