Keep your bounce rate under 3%. Verify your email list with catch-all email verifier Giggal.ai

Glossary · Authentication

What is SPF flattening?

The short answer

SPF flattening is a way to shorten an SPF record by replacing its include entries with the actual IP addresses they stand for. People do it to stay under SPF's limit of 10 DNS lookups. A flattened SPF record needs fewer lookups, but it has to be kept up to date.

Also called: flatten SPF record, SPF record flattening, SPF flattener, SPF compression

By · Updated · 4 min read

SPF flattening: what to remember

  • An SPF record is only allowed 10 DNS lookups. Go over, and SPF fails.
  • SPF flattening swaps include entries for plain IP addresses, which need no lookups.
  • The risk: providers change their IP addresses, and a flattened record does not update by itself.
  • A cold email domain that only sends through Google or Microsoft does not need SPF flattening.

What does SPF flattening mean?

To understand SPF flattening, you first need one fact about SPF.

SPF is the record in your DNS that lists who is allowed to send email for your domain. Most of the time you do not list servers one by one. You write a shortcut, called an include, that says “also allow everyone on this other company’s list”:

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

Each include is a pointer. To follow a pointer, the receiving mail server has to make a DNS lookup. And here is the rule that causes all the trouble: SPF allows only 10 DNS lookups.

SPF flattening is the fix. You replace the pointers with the actual IP addresses they lead to. IP addresses need no lookups, so the record becomes “flat”.

Think of a note on your front door that says “the spare key is with the neighbour, who left it with her sister, who gave it to a friend”. Every hop takes time. Flattening is replacing that note with the key itself.

Why SPF has a 10 lookup limit

The limit protects mail servers. Without it, someone could publish an SPF record that sends a server on thousands of lookups for every email, and slow it to a crawl.

The catch is that includes are nested. One include can contain three more inside it. A record that looks like it has four includes might really use twelve lookups.

When a record goes over 10, the result is not a warning. It is an SPF permerror, a permanent error, and SPF is treated as failed for every email you send.

An SPF flattening example

Before flattening. This record uses five services, and together they need more than 10 lookups:

v=spf1 include:_spf.google.com include:servers.newsletter.example
       include:mail.crm.example include:helpdesk.example
       include:spf.billing.example ~all

After flattening. The includes are replaced with the IP address ranges they stood for:

v=spf1 ip4:198.51.100.0/24 ip4:203.0.113.0/25 ip4:192.0.2.64/26
       ip4:198.51.100.128/27 ~all

The flattened record allows the same servers, but the receiving mail server reads the answer directly. It now needs zero lookups for those entries.

How SPF flattening works

  1. A tool reads your SPF record.
  2. It follows every include, and every include inside those, until it has the full list of IP addresses.
  3. It writes a new SPF record that lists those IP addresses directly.
  4. You publish the new record in your DNS in place of the old one.
  5. A good flattening service repeats this automatically, so the record changes when a provider changes its IP addresses.

The risk of SPF flattening

Flattening has one real danger: it goes out of date.

When you use an include, the other company keeps its own list current. When you flatten, you take a photo of that list on one day. If the provider adds new servers next month, your photo does not show them, and email sent from the new servers fails SPF.

That is why flattening by hand, once, is a bad idea. If you flatten, use a service that checks and rewrites the record on its own.

Do you need SPF flattening for cold email?

Almost never, and here is why.

A domain used for cold email should do one job: send from your inboxes. Its SPF record has a single include, for Google or for Microsoft, which uses only a few of the 10 lookups. There is nothing to flatten.

SPF flattening is a problem for busy company domains, where the same domain is used by the mailbox provider, a newsletter tool, a CRM, a help desk and a billing system all at once.

This is one more reason well-built cold email infrastructure keeps sending on separate domains: each domain has a short, simple SPF record that cannot hit the limit.

PureMail writes that record for you on every domain when it sets up your Google Workspace inboxes or Microsoft 365 inboxes.

What to try before SPF flattening

  • Remove services you no longer use. Old includes are the most common cause of going over the limit.
  • Move a service to a subdomain. Send newsletters from news.example.com, with its own SPF record and its own 10 lookups.
  • Drop entries you do not need. The a and mx entries each cost a lookup and are often not needed.
  • Never add a second SPF record. Two records on one domain is an error in itself.

How to count your SPF lookups

Paste your domain into an SPF checker such as MXToolbox. It shows your record, follows each include and tells you the total number of lookups. Under 10 is fine. Over 10 needs fixing, and SPF flattening is one of the ways to do it.

FAQ

SPF flattening: questions people ask.

01

What is SPF flattening in simple words?

SPF flattening means rewriting your SPF record so it lists IP addresses directly, instead of pointing to other companies' lists. Each pointer costs a DNS lookup, and SPF only allows 10. Flattening removes the pointers so you stay under the limit.

02

What is the SPF 10 lookup limit?

The rules for SPF say that checking one SPF record may trigger at most 10 DNS lookups. Entries such as include, a, mx and redirect each cost a lookup, and an include can contain more includes inside it. If the total goes over 10, the result is a permanent error and SPF fails.

03

Is SPF flattening safe?

It is safe only if it is kept up to date. Email providers add and change IP addresses without telling you. If your flattened SPF record still lists the old addresses, real email from the new ones fails SPF. Automatic flattening services exist to handle this, because doing it by hand goes stale.

04

Do I need SPF flattening?

Only if your SPF record goes over 10 lookups, which usually means five or more email services on one domain. First try removing services you no longer use, or moving a service to a subdomain. A domain that sends through a single provider is nowhere near the limit.

05

How do I check how many lookups my SPF record uses?

Paste your domain into a free SPF checker. It shows the full record, counts the DNS lookups and warns you if you are over 10.

Still have a question? support@puremail.ai · contact us

Your next reply is one order away.

Google Workspace and Microsoft 365 inboxes from $2.90 a month, set up and connected to your sequencer today.