SPF: too many DNS lookups

An SPF record may cause at most 10 DNS lookups while it's being checked, counting the ones inside every include. Past ten, SPF returns a permanent error (PermError), and to the receiver it's as if you had no SPF at all. The fix is to remove or replace includes until the total is ten or fewer.

What counts

The nesting is what catches people. An include looks like one lookup, but the record it points to can include others, and each of those counts too. Add a CRM, a helpdesk, a newsletter tool and an invoicing app, and you're past ten without noticing. The checker above walks the whole tree and gives you the real number.

Getting back under ten

  1. Remove what no longer sends. Old providers and tools you stopped using years ago are the usual first win. If you're not sure a service still sends, DMARC reports will tell you.
  2. Drop a, mx and ptr. They're often there by habit. ptr is discouraged by the standard itself. If your own server sends mail, list its IP as ip4: instead.
  3. Move senders to a subdomain. Send newsletters from news.example.com and give that subdomain its own SPF record. Each domain has its own limit of ten, and it keeps marketing mail's reputation apart from your team's.
  4. Flatten, with care. Flattening replaces includes with the IP addresses they currently resolve to. It works, but providers change their IPs, so a flattened record has to be kept up to date by a service, not by hand.

A related limit: void lookups

A lookup that returns nothing (an include pointing at a name that no longer exists) is a void lookup. More than two and many receivers treat SPF as broken too. They usually come from a tool you stopped using, so the fix is the same: remove the include.

Related