Skip to content
dnscheck.app

SPF record checker

Validate an SPF record and count its DNS lookups the way receivers do, including every nested include.

What SPF does

An SPF record is a TXT record that lists the servers allowed to send email for your domain:

example.com. TXT "v=spf1 ip4:192.0.2.0/24 include:_spf.google.com include:sendgrid.net ~all"

Receivers compare the sending server’s IP against the list. The mechanisms are tried left to right, and the final all says what to do with everything else.

How we count lookups

We follow the record the way a receiver does and count what RFC 7208 counts:

  • Count one each: include, a, mx, ptr, exists, and the redirect modifier.
  • Count nothing: ip4, ip6, all, and exp.
  • Nested includes count too. include:_spf.google.com costs one lookup, plus whatever Google’s record contains.

The include tree shows where each lookup comes from, so you can see which provider uses the most.

Fixing “too many DNS lookups”

  1. Remove includes for services you no longer send through.
  2. Replace a and mx with the ip4 and ip6 ranges they resolve to, if those addresses are stable.
  3. Check whether a provider offers a smaller include. Some have separate includes per region or product.
  4. Move some senders to a subdomain such as mail.example.com with its own SPF record.

The guide to SPF lookup limits walks through each option.

Other findings

  • +all lets anyone pass SPF. Always replace it.
  • ptr is deprecated and slow. Replace it with IP ranges.
  • Macros (%{i} and similar) are evaluated per message, so we cannot count what they resolve to.

Questions

What is the SPF 10 lookup limit?

While evaluating SPF, a receiver may perform at most 10 DNS lookups for include, a, mx, ptr, exists and redirect. ip4, ip6 and all are free. One lookup over the limit makes the whole record a PermError, and SPF fails.

What is a void lookup?

A term that points at a name with no records, such as an include for a domain that no longer exists. RFC 7208 allows at most two; beyond that, the result is PermError.

Should I use ~all or -all?

Both are fine when DMARC is enforcing (quarantine or reject), because DMARC decides what happens. Use ~all while you are still finding all your senders and -all once you are sure. Never use +all.

Can I have two SPF records?

No. Two records starting with v=spf1 is a PermError. Merge them into one record with all the includes.

Related tools

  • DMARC

    Policy, alignment, report addresses and syntax.

  • DKIM

    Find and validate DKIM keys by selector.

  • MX lookup

    Mail servers, priorities, and whether each one resolves.