MailHealthKit

SPF troubleshooting

SPF flattening

SPF flattening replaces include: mechanisms with the IP addresses they resolve to, so the record needs fewer DNS lookups. It can bring a record under the 10-lookup limit, but the copied addresses go stale when providers change them. Check a domain's lookup count below to see whether it's relevant.

No signup required. We look up public DNS records only.

  • DNS lookup count
  • 10-lookup limit
  • Include chain

About SPF flattening

What SPF flattening is

Each include: points at another domain's SPF record, which may include further records. Flattening resolves that chain ahead of time and publishes the resulting ip4: and ip6: ranges directly in your record. Those mechanisms don't need DNS lookups, so the record's count drops. The 10-lookup limit section explains which terms count.

Why it's used

A domain that sends through several services usually has an include for each, and some providers' records use several lookups on their own. One SPF record can contain several includes: each counts as one lookup toward the 10-lookup limit, plus the counted lookups in the record it includes. Once evaluating a message needs more than 10 DNS lookups, receivers return a permanent error for that message instead of a pass or fail. The check above shows how many counted lookups each top-level term in a domain's record contributes. Flattening is one way to bring the count back down without removing a sender.

Trade-offs

  • Addresses go stale. Providers change their sending ranges and update their own SPF records. A flattened copy doesn't follow, so mail from new addresses stops passing SPF until the record is updated.
  • It needs upkeep. Keeping a flattened record current means re-resolving the includes regularly, by hand or with a service that rewrites the record automatically.
  • Records get long. A list of address ranges can make the record large. Splitting it across several records adds lookups back.
  • It's harder to read. A list of addresses no longer shows which service each one belongs to.

Alternatives to try first

  • Remove includes for services that no longer send mail for the domain.
  • Remove duplicate includes and includes already covered by another one.
  • Remove ptr, which the SPF standard advises against and which costs lookups, and replace a or mx with ip4: or ip6: for servers you run and whose addresses you control.
  • Check whether a service needs to be in this record at all. Many send with their own or a subdomain's envelope sender, so SPF is checked against that domain instead.
  • Move some sending to a subdomain with its own SPF record.

Using the lookup count to decide

  • Within the limit with room to spare: flattening isn't needed.
  • At 9 or 10: the record works, but adding another service may push it over. Review it before adding one.
  • Over 10: reduce lookups. Start with the alternatives above; flatten if they aren't enough, and plan how the record will be kept current.
  • Not fully counted: part of the record couldn't be evaluated. Resolve that first, then check again.

What this check covers and its limits

  • The lookup count is what the checker counted at the time of the scan, following includes and redirects. Providers can change their records, which changes the count.
  • The check doesn't show which addresses a flattened record would contain, and this site doesn't generate flattened records.
  • Void lookups and the 10-host limit for mx aren't checked; see SPF PermError.
  • This result covers the lookup count only; the full checker reports every other SPF and DMARC finding.