← Back to Check a domain

SPF goes over its lookup limit

Your SPF record needs more than 10 DNS lookups once the records it includes are counted. A receiver that reaches the eleventh stops and returns an error instead of a pass, so mail from a service listed late in your record, or one it doesn't list, can fail SPF.

RFC 7208 section 4.6.4 sets the limit. Each include, a, mx, ptr and exists, and a redirect=, counts as one, and those inside the records you include count too: "SPF implementations MUST limit the total number of those terms to 10 during SPF evaluation". ip4, ip6 and all don't count.

On the result:

SPF goes over its lookup limit
Receivers stop after 10 DNS lookups, so mail from a service listed after that point fails SPF.

How the check counts

The check follows every include and redirect= in your record, and every one inside those, and adds up the terms above. It counts the whole record, not only up to the service that sends a given message, because a receiver checking mail from your last service, or from a server you never listed, can walk that far. The count is the most a receiver can need: it stops at the first entry that matches, so mail from a service listed early may still pass, and an included record that ends in +all means none of the later entries are ever read.

A service's include can cost more than one lookup, because it may include further records of its own. The service can change that without telling you, so a record that was under 10 can go over without any change on your side.

Look it up

Details → on your result shows your record. To count by hand, put your domain in place of example.com, then look up each include the same way:

dig +short TXT example.com
dig +short TXT _spf.example-service.com

On Windows, use nslookup -type=TXT with the same names.

Bring it under 10

  1. Remove services you no longer use. An old newsletter tool or a past mailbox provider is the usual find.
  2. Replace an a or mx entry with every address it stands for, IPv4 as ip4: and IPv6 as ip6:, if those addresses rarely change. Find them with dig +short A example.com and dig +short AAAA example.com for a, or dig +short MX example.com, then A and AAAA for each server it lists, for mx. If the servers' addresses change later, you have to update the record yourself. a and mx match both kinds, so leaving out the ip6: entries makes IPv6 mail fail. Keep any -, ~ or ? in front: ~mx becomes ~ip4:192.0.2.10 ~ip6:2001:db8::10, since a plain entry would pass servers the old one failed. Keep any prefix too. In a/24//64, /24 applies to IPv4 and //64 to IPv6, so it becomes ip4:192.0.2.0/24 ip6:2001:db8::/64. a/24 alone leaves IPv6 at single addresses: ip4:192.0.2.0/24 ip6:2001:db8::10.
  3. Remove a ptr entry: RFC 7208 section 5.5 says it "SHOULD NOT be published". Mail it passed then needs another entry, so check first which of your servers it was there for.
  4. Move a service to a subdomain. First publish the subdomain's SPF record with the service's include, for example at bounce.news.example.com. If your DMARC record has aspf=s, mail from example.com with a return address on the subdomain won't align, so first make sure DKIM passes for example.com itself, not only for the service's own domain. Then set the service to use that return address (Return-Path) in its domain settings. Keep the include in your main record until a test message shows spf=pass with smtp.mailfrom= naming the subdomain under Authentication-Results; then remove it.
  5. Run the check again.

If you still need more than 10, SPF explains hosted SPF, where MailGlo serves your services as addresses and keeps them current.

Last updated .