Guide

SPF flattening

Short answer

Flattening an SPF record means replacing terms that need DNS lookups, such as include, with the IP addresses they lead to. It gets a record under the limit of ten lookups, past which SPF returns a permanent error. The cost is upkeep: the addresses are a copy, and the copy goes out of date when a provider changes its own record. Remove unused senders, split senders across subdomains, and rely on DKIM before you flatten.

Last checked: . Every source is listed at the end with its own date.

The limit that causes the problem

An SPF record lists who may send mail for a domain. Much of the list is usually borrowed: each service you use gives you an include: term that points to a record the service maintains.

example.com  TXT  "v=spf1 include:_spf.mailhost.example include:send.crm.example include:mail.helpdesk.example ~all"

Every include makes the receiver do a DNS query, and the included record may contain more of them. The SPF standard, RFC 7208, caps this. Receivers must limit the terms that cause DNS queries to ten per check, counted across the whole evaluation, and must return permerror when the limit is passed.

Counts toward the tenDoes not count
include, a, mx, ptr, exists, redirectip4, ip6, all, exp

Two smaller limits sit beside it. An mx term must not lead to more than ten address lookups. And receivers should allow only two "void" lookups, meaning queries that come back empty or with a name error, which is what an include for a service that no longer exists produces.

A domain with a mailbox provider, a marketing platform, a CRM, a helpdesk and a billing system can pass ten without anyone noticing, because the count depends on what is inside records other people control.

What flattening does

Flattening resolves the lookups in advance. You follow each include, collect the addresses at the end of the chain, and publish those directly:

Before:  v=spf1 include:_spf.mailhost.example include:send.crm.example ~all
After:   v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.64/26 ip6:2001:db8:40::/48 ~all

The second record needs no lookups at all, because ip4 and ip6 terms do not cause queries. The standard's own advice on DNS cost points the same way: its example of the best record for a simple domain is one made only of ip4 terms.

The addresses above are documentation examples, not real senders.

What it costs

The copy goes stale

An include is a live reference. When the service adds or retires sending addresses, it edits its own record and yours follows. A flattened record is a snapshot. If the service changes its addresses and you do not, mail from the new addresses fails SPF, and nothing in your DNS shows why. The standard names this trade-off in general terms: terms that use lookups let hosts be renumbered easily, at the price of a query.

The record gets long

Large senders publish many ranges. The standard asks that an SPF answer stay small enough to fit in 512 octets, with a working guideline of 450 for the name and all the TXT records at it together, and warns that longer answers can be silently ignored where DNS over TCP is blocked. A single string in a TXT record is also limited to 255 octets, so a long record has to be split into several strings, which receivers join without adding spaces.

Someone has to keep doing it

Flattening is not a one-time fix. Either a person re-checks the provider records on a schedule, or a tool does. If you hand the job to an outside service, part of your SPF record is run by that service, and your mail depends on it.

What to try first

  1. Remove senders you no longer use. Old include terms for cancelled services are the cheapest lookups to recover, and the DMARC standard asks owners to review their SPF records periodically in any case.
  2. Check whether each service needs to be in your SPF record at all. SPF is checked against the envelope sender, not the From line. A platform that uses its own domain there is never checked against your record, so its include only spends a lookup.
  3. Give services their own subdomains. Each name has its own record and its own budget of ten. Marketing mail sent with an envelope domain of news.example.com uses that name's SPF record. Under DMARC's relaxed alignment, a subdomain of the same organisation still matches a From address at example.com.
  4. Replace expensive terms. The standard recommends ip4 and ip6 over a, and a over mx, where addresses rarely change. Swapping a bare mx for the addresses of your own servers is flattening too, but of something you control.
  5. Lean on DKIM. DMARC passes when either SPF or DKIM passes with a matching domain. A service that signs with your domain passes DMARC even if it is not in your SPF record. The DMARC standard goes further for domains at p=reject: they must not rely on SPF alone and must sign with DKIM.

If the record is still over ten after all of that, flatten the part that changes least, and keep the rest as include terms.

If you do flatten

  • Write down which addresses came from which service and when you copied them.
  • Re-check on a schedule, and whenever a provider announces a change to its sending addresses.
  • Keep exactly one SPF record at the name. The standard treats more than one as a permanent error.
  • Watch your DMARC aggregate reports afterwards. A rise in SPF failures from one service is the sign that its addresses moved.

Where this meets DMARC and BIMI

An SPF permerror is not a DMARC failure by itself. It means SPF gave no pass, so DMARC falls back on DKIM. Mail that is signed with your domain still passes, and a BIMI logo still qualifies. The mail at risk is whatever relies on SPF alone, which is often the mail from older or simpler systems.

The DMARC checker reports whether an SPF record exists and whether there is more than one. It does not count lookups.

Questions and answers

What is the SPF 10 lookup limit?
The SPF standard says a receiver must stop after ten terms that need a DNS query while checking one message: include, a, mx, ptr, exists and redirect. Terms inside included records count too. Past ten, the result is a permanent error.
Does SPF flattening affect DMARC or BIMI?
Indirectly. A record over the limit gives an SPF error, so SPF cannot produce a pass. DMARC can still pass on DKIM alone, and BIMI needs only that DMARC passes. Flattening matters most for mail that has no aligned DKIM signature.
Do ip4 and ip6 entries count toward the limit?
No. The standard lists ip4, ip6 and all as terms that cause no DNS queries, which is why flattening works.
Is flattening part of the SPF standard?
No. It is a name for a workaround. The standard defines the limit and the mechanisms; it does not describe flattening or any service that does it.

Sources

  1. IETF, RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1 (published April 2014; checked 2026-12-05)
  2. IETF, RFC 9989: Domain-Based Message Authentication, Reporting, and Conformance (DMARC) (published May 2026; checked 2026-12-05)

This page is general information. It is not legal advice, and it is not a statement from any mailbox provider or certificate issuer. Each provider decides what it displays.