SPF flattening risks

Flattening replaces an include with the IP ranges it resolves to today. It saves lookups, but you take over a job the sending service used to do: keeping its address list current.

What goes wrong

Sending services change their ranges without telling you. They only promise that their own include stays correct. A flattened copy is a snapshot, so the day a provider adds a new range, mail from it fails SPF.

Under DMARC, an SPF fail only hurts when DKIM also fails or is not aligned. That is why a broken flattened record often goes unnoticed for weeks: most mail still passes on DKIM, and the failures show up only in aggregate reports.

Some terms cannot be flattened at all: exists, ptr and anything with a macro such as %{i} depend on the message being checked.

If you flatten, watch it

  • Re-resolve each flattened include on a schedule (every few hours) and compare with what you published.
  • Change the record when the provider's ranges change, through the same review as any other DNS change.
  • Keep the record under the size a single DNS response can carry; RFC 7208 section 3.4 warns that large records may be truncated over UDP.
  • Prefer flattening one large include over flattening everything.

A hosted SPF record does the same thing on infrastructure that is watched for you: your record has one include pointing at a record the service keeps up to date. Either way, the include you publish is the only part receivers look up.

Alternatives that need no upkeep

Removing unused senders and moving bulk mail to a subdomain both reduce lookups without copying anyone's address list. Try those first; see the SPF lookup limit.