SPF records explained: mechanisms, qualifiers and the lookup limit

By the LeadsPaw team · Last updated

An SPF record is a single DNS TXT record that lists which senders are authorized to send mail for your domain. It looks deceptively simple - v=spf1 include:_spf.google.com ~all - but every term in it has a defined meaning in RFC 7208, and one invisible limit breaks oversized records outright. This guide walks through the mechanisms, the qualifiers and that limit, with the RFC's own definitions.

The version tag, and one record only

A verifier collecting your domain's TXT records keeps only the ones that begin with exactly v=spf1 - per the RFC, a version section like v=spf10 does not match and is discarded. If no SPF record remains, the result is none; if more than one remains, the result is permerror, which the RFC defines as an error condition that definitely requires DNS operator intervention. One domain, one SPF record.

Mechanisms: what each term matches

After the version tag, the record is a list of terms evaluated in order. The mechanisms you will meet most:

  • include - triggers a recursive evaluation of another domain's SPF record and uses its result. The RFC notes the name was, in hindsight, poorly chosen: the referenced record's mechanisms are not literally copied in, only its evaluated result is used. This is how you authorize a provider like Google by pointing at its record.
  • a, mx, ptr, exists - mechanisms that resolve DNS data about the domain during evaluation.
  • ip4 and ip6 - explicit address ranges listed directly in the record.
  • all - a test that always matches. It is used as the rightmost mechanism to provide an explicit default; the RFC says anything after all is never tested and must be ignored.

If none of the mechanisms match and there is no redirect modifier, the RFC treats the result as neutral - as if ?all had been written at the end - but recommends terminating the record explicitly to aid debugging.

Qualifiers: what happens when a mechanism matches

Each mechanism can carry one of four qualifiers, and each maps to a result with a precise RFC definition:

  • + pass (the default when no qualifier is written) - an explicit statement that the client is authorized to inject mail with the given identity.
  • - fail - an explicit statement that the client is not authorized to use the domain in the given identity.
  • ~ softfail - a weak statement by the publishing domain that the host is probably not authorized; it has not published a stronger, more definitive policy that results in fail.
  • ? neutral - the domain explicitly states it is not asserting whether the IP address is authorized.

Two more results come from the plumbing rather than your policy: temperror (a transient, generally DNS, error - a later retry may succeed) and permerror (your published records could not be correctly interpreted).

The 10-lookup limit that breaks big records

Here is the constraint that catches growing setups. To avoid unreasonable load on the DNS, RFC 7208 requires implementations to limit the terms that cause DNS queries during evaluation - the include, a, mx, ptr and exists mechanisms and the redirect modifier - to 10. Exceed the limit and the implementation must return permerror. The all, ip4 and ip6 terms cause no queries at evaluation time and are not subject to the limit. A separate recommended cap limits "void lookups" - queries that return empty or name-error answers - to two.

Stacked include terms are how records cross the line: every provider you authorize adds its own record's lookups to your count. When you are setting the record up alongside DKIM and DMARC, our setup guide walks through the DNS work, and the DMARC policies guide explains what happens to mail that fails these checks. For Google's requirements at volume, see Gmail's bulk sender rules.

Frequently asked questions

What does v=spf1 mean at the start of the record?

It is the version tag that identifies the TXT record as an SPF record. Per RFC 7208, a verifier starts with the TXT records returned for the domain and discards any that do not begin with exactly v=spf1. If none remain, the result is none; if more than one SPF record remains, the result is permerror.

What happens if my SPF record needs more than 10 DNS lookups?

RFC 7208 requires SPF implementations to limit the terms that cause DNS queries - the include, a, mx, ptr and exists mechanisms plus the redirect modifier - to 10 during evaluation. If the limit is exceeded, the implementation must return permerror, meaning your record could not be interpreted.

Should I use ~all or -all at the end of my record?

They are different policy statements, defined in RFC 7208: -all produces fail, an explicit statement that the client is not authorized; ~all produces softfail, a weak statement that the host is probably not authorized. The RFC defines the results but leaves the choice to the domain owner - neither is declared the correct one.

Does SPF alone stop spoofing of my domain?

No. SPF authorizes sending hosts, but it does not tell receivers what to do when a message fails - dmarc.org's overview describes that gap as the reason DMARC exists. DMARC adds the policy layer and reporting; see our guide to DMARC policies.