Back to field guides
Primer · SPF

SPF, from first principles.

8 min read·Updated 2026-04

SPF (RFC 7208) is a DNS record that lists the servers allowed to send email on your domain's behalf. It's the simplest of the three email-auth standards and also the most often misconfigured — usually because someone ran past the 10-lookup limit without realising it exists.

What SPF actually checks

When a receiver gets a message claiming to be from marketing@acme.com, it pulls the envelope sender (MAIL FROM) and looks up the SPF TXT record at that domain. Then it asks: does this record authorise the IP address that just connected to me?

SPF answers in one of five ways: pass, fail, softfail, neutral, or none (no record). It does not say what the receiver should do about a fail. That's DMARC's job.

Anatomy of a record

acme.com.   IN TXT  "v=spf1 mx include:_spf.google.com
                       include:servers.mcsv.net
                       ip4:198.51.100.0/24
                       -all"

Mechanism by mechanism:

The 10-lookup cliff

RFC 7208 caps SPF resolution at 10 DNS lookups. Every include:, a:, mx:,exists:, ptr:, and redirect= mechanism counts. If your record exceeds 10, the receiver evaluates SPF as permerror, which fails DMARC alignment on SPF without giving you any obvious error.

This is the single most common SPF bug we see in production. Operators add include:_spf.google.com, include:servers.mcsv.net, include:spf.protection.outlook.com, include:_spf.salesforce.com, include:sendgrid.net — and that's 5 lookups before counting recursion. Each of those records often contains its own includes. Salesforce alone resolves to about 7 lookups. You're past 10 before you notice.

The cliff is silent. There is no error in your sent mail. There is no bounce. Receivers just stop counting SPF as a vote in your favour. Your DMARC reports show messages failing alignment on SPF; you scratch your head; you never look at the lookup count because no tool surfaces it. We built one: SPF lookup counter. It walks the tree and tells you exactly which include pushed you over.

Flattening — what it is, when to do it

When you can't reduce includes (every ESP genuinely needs to be authorised), the alternative is flattening: replacing include:vendor.com with the actual ip4: ranges that vendor publishes. That collapses a 7-lookup include into 0 lookups (just literal IPs).

The trade-off:

Doing this manually is tedious. Mailstinger's hosted SPF auto-flattens when you exceed the cap and re-resolves the includes nightly so the published IPs stay current. The point isn't that flattening is magic; the point is that the routine maintenance shouldn't be your routine.

The terminator — the choice that actually matters

-all, ~all, ?all, +all. These mean different things and the difference is visible in your spam folder.

What changed in 2024

Google and Yahoo's February 2024 sender requirements tightened the SPF math. For bulk senders (anyone over ~5,000 messages a day to those providers), SPF must pass for DMARC alignment — not just exist. Apermerror from being over the lookup limit is now a deliverability problem, not just a hygiene one.

The audit you should do today:

  1. Run the SPF lookup counter on your domain.
  2. If lookup count ≤ 8, you're fine; verify-all and move on.
  3. If lookup count is 9 or 10, you have one bad addition away from the cliff. Trim or flatten now.
  4. If > 10, you are silently failing SPF alignment for some mail right now. Flatten today.

Things people get wrong

Where to read next