Two SPF terms let one record pull in policy from somewhere else: include and redirect. They look similar, people use them interchangeably, and getting the difference wrong is a common way to quietly break mail or blow past SPF's lookup limit. This guide explains exactly how include and redirect differ, how each one affects the ten-lookup budget, and when flattening a record is a sensible fix versus when it sets a trap for future you.
What include actually does
The include mechanism tells the receiver to evaluate another domain's SPF record as part of yours. If a message's sending IP matches inside the included record, the include produces a match and your record can pass. Critically, include only ever contributes a pass. If the included record does not match the IP, evaluation simply continues to the next term in your record. The included record's own all is ignored for the purpose of your result; it cannot cause your record to fail or to stop early. This is why you can safely chain several includes in a row, each one a sending platform, and finish with your own all qualifier.
v=spf1 include:_spf.google.com include:servers.mcsv.net ~all
What redirect does differently
The redirect modifier is a replacement, not an addition. It says: stop using this record and use the target domain's record as the authoritative policy for this domain instead, including its all. Because the target's all becomes your effective result, a redirect must be the whole story. You do not put your own all in a record that uses redirect; if you do, the all wins and the redirect is ignored. Redirect is designed for the case where many domains should share one centrally managed policy.
v=spf1 redirect=_spf.example.com
The difference at a glance
| Behavior | include | redirect |
|---|---|---|
| Role | Adds another record's passes | Replaces the whole policy |
| Target's all applies to you | No, ignored | Yes, becomes your result |
| Combine with your own all | Yes, you supply the final all | No, must not have one |
| If target does not match | Continue to next term | Target's all decides the result |
| Typical use | Listing several senders | One shared policy for many domains |
How each affects the ten-lookup limit
SPF caps the number of DNS-querying terms a receiver will follow at ten, counted across the whole evaluation. Both include and redirect count as one lookup each, and, importantly, so does every DNS-querying term inside the record they point to. A single include that resolves to a record containing three more includes can therefore cost you four lookups, not one. Exceed ten and the receiver returns a permerror, which most treat as if SPF had failed to produce a pass. This nesting is the usual reason a record that looks short in your zone file is actually over budget, and it is why counting lookups means following every reference all the way down.
What flattening means and when it helps
Flattening is the practice of replacing include and redirect references with the actual ip4 and ip6 addresses they ultimately authorize, collapsing a nested tree of lookups into one flat list of IP ranges. Because bare IP mechanisms do not trigger DNS lookups, a flattened record can list dozens of networks while costing zero of your ten lookups. When a legitimate set of senders genuinely pushes you over the limit, flattening is the standard escape hatch.
- Resolve every include and redirect in your current record down to the IP ranges each one publishes.
- Collect those ranges into
ip4andip6mechanisms in a single record. - Keep your original qualifier, usually
~allor-all, at the end. - Verify the flattened record stays under the 255-character-per-string limit, splitting into multiple strings if needed.
- Publish and confirm it parses cleanly before relying on it.
Why flattening can quietly break mail
Here is the trap. When you flatten, you freeze a snapshot of your senders' IP ranges at one moment. But the whole point of a provider publishing an SPF record is that they change their sending IPs whenever they need to, and expect your include to pick up the change automatically. A flattened record does not update itself. The day your email provider adds a new mail server or renumbers, your frozen list no longer authorizes it, and that mail starts failing SPF with no obvious cause. Flattening therefore trades a lookup-limit problem for a maintenance obligation: either you re-flatten on a schedule, or you use a service that re-flattens and republishes for you. If you can solve the limit any other way, prefer that.
Structuring a record the sane way
Before flattening, try cheaper fixes. Remove includes for services you no longer use, since stale includes are the most common source of wasted lookups. Consolidate where a provider offers a single leaner include. Move rarely used senders to a subdomain with its own record so your primary domain's budget is not consumed by an occasional newsletter tool. Only when a genuinely necessary set of senders still exceeds ten lookups should you reach for flattening, and then with a plan to keep it current.
- Audit the record and drop every include for a service you have stopped using.
- Count the true lookup cost by following each reference to the bottom.
- Prefer consolidation and subdomain separation over flattening.
- If you must flatten, document which provider each IP block came from so you can refresh it.
- Re-check with an SPF record checker to confirm the lookup count and syntax after any change.
Can I use both include and redirect in one record?
You can technically have includes and a redirect, but it is almost never what you want. A redirect only takes effect when no mechanism has already matched and there is no all present, so mixing them produces confusing results. Use includes with your own all, or a single redirect, not both.
Does redirect reset the lookup counter?
No. A redirect counts as a lookup, and every DNS-querying term in the target record counts too, all against the same limit of ten. Redirect does not give you a fresh budget.
Why does my short SPF record fail with a permerror?
Almost always because of nesting. An include that points to a record containing more includes multiplies the lookup count, so a record with only two or three visible terms can exceed ten once fully resolved. Count the whole tree, not just the top line.
Is flattening safe to do once and forget?
No. Flattening freezes your providers' IP ranges, and those change without warning. A flattened record needs periodic refreshing or an automated service that re-flattens, otherwise mail from newly added servers will start failing SPF.
Should small domains worry about any of this?
Only if they exceed ten lookups, which most small domains do not. If a couple of includes and your own all stay under the limit, leave the record static and simple. Flattening is a remedy for a real limit problem, not routine hygiene.
Pick include when you are adding senders and keeping your own final policy, and redirect only when many domains should share one managed record. Treat flattening as a last resort with a maintenance plan attached. For the related problem of forwarded mail failing SPF even when your record is correct, see our guide on why email forwarding breaks SPF, and for the final qualifier that decides the outcome, our guide to SPF all mechanisms.