SPF Record Checker
Validate a domain's SPF record, count its DNS lookups against the limit of 10, and see every include and IP range it authorises.
Enter the domain that sends the mail (the part after the @). Email addresses and URLs are trimmed to the domain. Press Enter to check.
Results
What an SPF record does
Sender Policy Framework (SPF, RFC 7208) lets a domain publish, in a DNS TXT record, the list of servers allowed to send mail using that domain in the envelope sender – the hidden Return-Path address that bounces go back to. When a message arrives, the receiving server takes the IP address that connected to it, fetches the SPF record of the envelope domain and works through it from left to right until something matches. The first match decides the result: pass, fail, softfail or neutral.
A record looks like v=spf1 include:_spf.google.com ip4:192.0.2.0/24 -all. Each space-separated term is either a mechanism that can match the sending address, or a modifier such as redirect=. This checker fetches the record, parses every term, follows every include and redirect, and reports anything a receiver would object to.
The 10-lookup limit, explained
Evaluating SPF can make the receiving server perform further DNS queries, and an attacker could otherwise use that to turn every mail server into a DNS amplifier. RFC 7208 §4.6.4 therefore caps the work. The terms include, a, mx, ptr and exists, and the redirect modifier, each cost one lookup, and the total across the whole policy – including everything inside every include, however deeply nested – must not exceed 10. The terms ip4, ip6 and all cost nothing because they need no DNS.
There are two further limits. An mx term may lead to at most 10 mail-server hostnames, each of which must then be resolved to addresses. And no more than 2 lookups should be void – a name that does not exist, or exists with no records of the type asked for (the RFC recommends this limit rather than requiring it). Break any of these and a receiver enforcing them stops with a permerror. Under DMARC a permerror counts as an SPF failure, so mail that should pass silently loses one of its two routes to authentication.
The limit creeps up on people because every service you add (a CRM, a help desk, a newsletter platform) asks you to add its include, and each of those includes may contain several more. You only see the top layer in your own DNS.
Reading the include tree
- Cost on each branch is the number of lookups that branch adds: one for the include or redirect itself, plus everything inside it.
- Running total shows the count before and after the branch, in the order a receiver evaluates the record. The term that takes the total to 11 is marked, with the full path from your record down to it, so you can see which provider's include tipped you over.
- Terms after
allare greyed out: evaluation stops atall, so they are never reached and cost nothing – but they are almost always a mistake. - Includes that use macros (for example
exists:%{i}._spf.example.com) depend on the message being checked. They are counted, but cannot be followed here.
The "all" mechanism
-all(fail) – anything not listed should be rejected. The strictest setting.~all(softfail) – anything not listed is suspicious. With DMARC at quarantine or reject this is a perfectly sound choice, and it is what Google, among others, publishes.?all(neutral) – says nothing at all about unlisted senders, so SPF provides no protection.+all– authorises every IP address on the internet to send as your domain. Never correct.- No
alland noredirect=– the default result is neutral, the same as?all.
Other problems this checker flags
- No SPF record, or more than one. Two records starting
v=spf1are a permerror; merge them into one. - Syntax errors such as
ip4:with an invalid address, a prefix length out of range,redirect:written with a colon, or a misspelt mechanism. One error invalidates the whole record. - The deprecated
ptrmechanism. It is slow and unreliable, RFC 7208 says not to use it, and some receivers skip it. - An include pointing at a domain without SPF, which is a permerror rather than a harmless no-op, and include loops.
- Very wide ranges, such as an
ip4covering millions of addresses, which usually means someone authorised a whole provider network.
How to fix "too many DNS lookups"
- Remove includes for services you no longer use. This alone is often enough.
- Replace
aandmxwith theip4/ip6addresses they resolve to, if those addresses are stable. - Move bulk or marketing mail to a subdomain (such as
news.example.co.uk) with its own SPF record and its own budget of 10. - Consider whether a service needs SPF at all. If it signs your mail with DKIM using your domain, DMARC can pass on DKIM alone, and its include is optional.
- "Flattening" (replacing includes with the IP addresses they currently contain) works, but the provider's addresses change without notice, so only do it with a tool that refreshes the record automatically.
Limitations
This checker reads DNS through Cloudflare's public resolver, so it sees the records as cached there; a change you have just made may take up to the old TTL to appear. It can tell you whether a policy is valid and what it authorises, but not whether a particular message will pass: that depends on the IP address the message actually came from and on the envelope domain the sending service used, which is often the provider's own domain rather than yours. SPF also breaks when mail is forwarded, because the forwarding server is not in your record – one reason DKIM and DMARC matter as much as SPF. To check those, use the DMARC and DKIM checker.
Common questions
How many DNS lookups does SPF allow?
SPF allows a maximum of ten DNS lookups when a record is evaluated, a limit set by RFC 7208. The include, a, mx, ptr and exists mechanisms and the redirect modifier each count as one, including those nested inside includes, while ip4, ip6 and all cost nothing. Exceeding ten produces a permerror, which DMARC treats as an SPF failure.
What is the difference between ~all and -all in SPF?
The difference between ~all and -all in SPF is how firmly unlisted senders are treated. -all is a fail, saying mail from any server not listed should be rejected, while ~all is a softfail that marks such mail as suspicious. With a DMARC policy of quarantine or reject in place, ~all is a sound choice.
Can a domain have two SPF records?
A domain cannot have two SPF records. If two TXT records beginning v=spf1 are published at the same name, receivers return a permerror and SPF stops working for the domain's mail. The fix is to merge them into a single record that contains every mechanism from both, with one all term at the end.
Why does SPF fail when an email is forwarded?
SPF usually fails on forwarded email because the forwarding server's IP address is not listed in the original sender's SPF record. The receiver checks the address that connected to it, which is now the forwarder's. A DKIM signature normally survives forwarding, so the message can still pass DMARC through DKIM.