SPF checker
Enter a domain to see its SPF record explained, how many of the 10 allowed DNS lookups it needs and what happens to mail from other servers.
Create an SPF record
TXT record for your domain (host @)
v=spf1 mx ~allKeep one SPF record per domain. Every include, mx and a costs a DNS lookup and providers often add more, so check the published record above.
What SPF does
SPF is a TXT record that lists the servers allowed to send mail for your domain. Receiving servers compare the sending server with this list and use the result for their spam decision and for DMARC.
A record must stay below 10 DNS lookups, or receivers treat it as broken. End it with ~all while you collect your senders and switch to -all once every service is listed.
How an SPF record is built
An SPF record always starts with v=spf1. Then come mechanisms that the receiving server checks from left to right. The first match decides; nothing after it is read.
ip4:andip6:allow an address or a network, such asip4:203.0.113.5orip6:2001:db8::/32.aallows the addresses in the domain's A and AAAA records,mxthe addresses of its mail servers. Both work for other names too, for examplea:mail.example.com.include:pulls in the record of another domain. It only matches if that record returns "pass" for the server. A-allin the included record does not make yours fail; evaluation simply moves on to the next mechanism.exists:matches if the given name has an A record. It is mostly used with macros.allmatches every server, so it belongs at the end.redirect=is a modifier: if nothing matches, the record of another domain applies. If the record contains anall,redirectis ignored.
Each mechanism can carry a qualifier: + for "pass" (the default when there is none), - for "fail", ~ for "softfail" and ? for "neutral". If nothing matches and there is no redirect, the result is "neutral".
How SPF works with DKIM and DMARC is covered in SPF, DKIM and DMARC explained.
What counts towards the ten DNS lookups
The terms that count are include, a, mx, ptr, exists and redirect, including those inside included records. ip4, ip6 and all cost nothing. A single include from a large provider can use several lookups, because its record contains further include terms.
There is a second limit (RFC 7208, section 4.6.4): if more than two lookups come back empty, for example because a name after a: no longer exists, receivers should stop. Both limits end in "permerror", and this checker counts both.
How to stay below them:
- Remove old services. The
includeof a provider you no longer use still costs lookups. - Replace
aandmxwithip4if the addresses of your servers rarely change. - Use subdomains. If your newsletter tool sends with
news.example.comas its Return-Path, that subdomain gets its own record with its own ten lookups.
Flattening replaces every include with the IP addresses behind it. That saves lookups but is risky by hand: when a provider changes its servers, your mail fails without you noticing.
Building a record step by step
Say example.com uses Google Workspace for its mailboxes, a newsletter tool and its own server for invoices.
- Collect every sender: mailboxes, newsletters, shop, help desk, office servers.
- Take the
includefor each service from its documentation. For Google Workspace that isinclude:_spf.google.com, for Microsoft 365include:spf.protection.outlook.com. - Check which domain the service uses as its Return-Path. Many newsletter tools send with their own bounce domain. SPF is then checked for that domain, and an
includein your record achieves nothing. - Add your own servers with
ip4orip6. - End the record with
~alland switch to-allonce your DMARC reports no longer show forgotten senders.
example.com. TXT "v=spf1 include:_spf.google.com include:_spf.newsletter.example ip4:203.0.113.5 ~all"
Two things are easy to forget. Subdomains do not inherit SPF: shop.example.com needs its own record if it sends mail. And a domain that sends no mail should say so:
example.org. TXT "v=spf1 -all"
How to read the result
At the top is the record, below it every part with its meaning. The checks list problems first.
- "DNS lookups: 7 of 10" includes every nested record. Above 10, it turns into "Too many DNS lookups", and receivers treat the whole record as an error.
- "… has no single SPF record" means there is no record, or more than one, behind an
includeorredirect. That is a "permerror" too. - "… leads back to a record already read" reports a loop.
- "… lookups find nothing" lists terms such as
a:old.example.comor anincludewhose DNS lookup comes back empty. With three or more, the line turns into "Too many lookups without an answer". Terms with macros (%{i}) andptrdepend on the sending server and are not checked. - The check on
alltells you what happens to servers that are not listed.+allis an error,?alland a missingallare warnings, unless aredirectsupplies the policy. - The warning about
ptrconcerns a mechanism that is slow and no longer recommended by RFC 7208.
Whether real mail passes SPF only shows with a test message. Send one to the mail tester and see which domain was checked.
Common questions
What is the difference between fail, softfail and permerror?
"fail" (-all) is a clear statement that the server may not send. "softfail" (~all) means "probably not allowed": receivers should not reject the mail on that basis alone, but look at it more closely. "permerror" means the record is broken, for example because of too many lookups or a typo. For DMARC, only a "pass" counts, and only if the checked domain matches the "From".
Why does SPF fail for forwarded mail?
A forwarded mail arrives from the forwarding server's address, but its Return-Path is still yours. That server is not in your record, so SPF fails. Some forwarders rewrite the Return-Path (SRS). The safer route is to sign with DKIM as well, because the signature survives forwarding.
Do I still need the SPF record type?
No. RFC 7208 retired the separate SPF record type. Only the TXT record counts.