SPF explained: what every part of the record does, and how to fix it
SPF (Sender Policy Framework) is a list, published in your domain's DNS, of the servers allowed to send email for that domain. Receiving mail servers read it to decide whether to trust a message. It is short, but every part of it has a precise meaning, and a small mistake can quietly send your mail to spam. This page explains all of it, and the tool below explains your own record one term at a time.
Explain my SPF record
A pasted record is explained in your browser and never sent anywhere. For a domain, we also follow every include: to count the real number of DNS lookups.
How an SPF check works
- A message arrives at a receiving mail server from some IP address.
- The receiver takes the domain from the envelope sender (also called the Return-Path or MAIL FROM address). This is not the “From” address you see in your mail app. If there is no envelope sender it uses the name the sending server announced (HELO).
- It looks up that domain's TXT records and finds the one that starts with
v=spf1. - It reads the terms left to right. The first term that matches the sending IP address decides the result, and the rest are ignored.
- If nothing matches, the result is “neutral” (unless the record ends with a
redirect=). - The receiver combines that result with DKIM, DMARC and its own knowledge of your reputation. SPF alone rarely decides whether mail is delivered.
The anatomy of a record
v=spf1 ip4:203.0.113.10 include:_spf.google.com mx ~all
v=spf1: the version. Always first.ip4:203.0.113.10: a mechanism. Allow this one address.include:_spf.google.com: another mechanism. Also allow whatever Google's list allows.mx: another mechanism. Allow my own mail servers.~all: the ending. Everything not matched above is “suspicious”. The~in front is a qualifier.
Terms come in three kinds: mechanisms (who is allowed), qualifiers (what result a match gives) and modifiers (extra instructions).
Qualifiers: what a match means
Any mechanism can have one symbol in front of it. With none, + is assumed.
| Symbol | Result | Meaning in practice |
|---|---|---|
+ (or nothing) | Pass | This sender is allowed. |
- | Fail | This sender is not allowed. Receivers usually reject the message or send it to spam, but each receiver decides for itself. |
~ | Softfail | This sender is probably not allowed. Mail is normally accepted but treated with suspicion. |
? | Neutral | No opinion. Treated almost as if there were no SPF record. |
Mechanisms: who is allowed
| Term | It matches when… | DNS lookups | Watch out for |
|---|---|---|---|
all | Always. It catches everything not matched before it. | 0 | Put it last. Terms after it are never read. +all allows the whole internet. |
ip4:203.0.113.10ip4:203.0.113.0/24 | The sending IPv4 address equals the address, or falls in the range. /24 means 256 addresses. | 0 | The cheapest and most precise term. Make sure the range is really yours. |
ip6:2001:db8::/32 | The same, for IPv6 addresses. | 0 | If your server sends over IPv6 and you only list IPv4, mail sent over IPv6 fails. |
aa:mail.example.coma/24 | The sending address is the A (or AAAA) record of your domain, or of the host you name. A slash adds the neighbouring addresses. | 1 | Handy when your website server also sends mail. Meaningless if you send through a provider. |
mxmx:other.com | The sending address is one of the domain's mail servers (its MX records). | 1 | Right only if the servers that receive your mail are also the ones that send it. With Google or Microsoft hosting that is usually not the whole story. |
include:_spf.google.com | The other domain's SPF record says this sender is allowed (a “pass”). | 1 plus everything inside that record | The main way to authorise a provider. If their record says “fail”, that is not a match here; the search carries on. A typo or a domain with no SPF record breaks the whole record. |
exists:%{i}._spf.example.com | A DNS lookup of that name finds any address. Macros such as %{i} insert the sender's IP into the name. | 1 | Used by some big providers to approve individual servers. Almost never needed in a hand-written record. |
ptr | The sender's reverse DNS name ends in your domain. | 1 | The standard says it should not be published: it is slow and unreliable. Replace it with ip4 or include. |
Modifiers: extra instructions
| Term | What it does | Lookups |
|---|---|---|
redirect=example.com | If no mechanism matched, use the SPF record of that domain instead, as though it were this record. It replaces an all, so a record has one or the other, never both. Good for many domains that should share one list. | 1 |
exp=explain.example.com | Names a TXT record whose text is shown to people whose mail fails. Very rarely used. | 0 in normal use |
anything else, such as foo=bar | Unknown modifiers are ignored, so a typo here does nothing, silently. An unknown mechanism, by contrast, makes the whole record invalid. | 0 |
The results a receiver can reach
| Result | Meaning | Usual cause |
|---|---|---|
| pass | The sender is allowed. | Matched a term with + (or no symbol). |
| fail | Not allowed. | Matched -, usually the -all at the end. A server you forgot to list. |
| softfail | Probably not allowed. | Matched ~all, so a sender is missing from the list or someone is forging your domain. |
| neutral | No opinion. | Matched ?, or nothing matched and there is no all. |
| none | No SPF record found. | The record was never published, or is on the wrong name. |
| temperror | A temporary DNS problem. | A DNS server was slow or unreachable. Usually clears on retry. |
| permerror | The record is broken. | Too many lookups, two SPF records, a typo in an include or a term the receiver does not know. Receivers treat this like a failure. |
The limits that cause most SPF failures
These come from the standard (RFC 7208). Breaking any of them makes the record fail even though it looks fine.
- No more than 10 DNS lookups. The terms
include,a,mx,ptr,existsandredirecteach cost one, and the ones inside an included record count too.ip4,ip6andallare free. Over 10 means permerror. This is the most common hidden failure, because each provider you add brings its own lookups. - No more than 2 “void” lookups. A void lookup is one that finds nothing (a typo, or an include of a domain with no SPF record). More than two is an error.
- Only one SPF record per domain. Two records is a permerror, even if each is correct on its own. Merge them.
- Keep it small. The DNS answer should fit in 512 bytes. A single DNS text string holds at most 255 characters, so longer records are stored as several strings that receivers join with no space between them. Most DNS panels do the splitting for you.
- It must be a TXT record. The old dedicated SPF record type is no longer used.
If you are over 10 lookups
- Remove what you do not use. Includes for tools nobody uses any more are the usual cause. Check what actually sends your mail first.
- Use a subdomain for each sending service. Send newsletters from
news.example.comand give that name its own short SPF record, so the main domain's record stays small. - Swap an include for fixed addresses (
ip4) only if the provider promises the addresses do not change. If they do, your record silently goes stale and mail starts failing. - Avoid
ptr, and be sparing withaandmx. Each costs a lookup that anip4would not. - “Flattening” replaces includes with the addresses inside them. It works, but the addresses must be kept up to date, which is easy to forget. Treat it as a last resort and set a reminder to re-check.
Which ending should I use?
| Ending | What happens to mail from unlisted servers | Use it when |
|---|---|---|
-all | Failed. Many receivers reject it or spam-folder it. | You control every sender and have tested. It also risks rejecting some legitimate forwarded mail (see below). |
~all | Softfailed. Usually delivered but marked suspicious. | You are setting up, or you publish DMARC and prefer to let it make the final decision. A very common, sensible choice. |
?all | Neutral. Treated as if SPF were not there. | Almost never. It gives no protection. |
+all or all | Passed. Anyone can send as your domain. | Never. It cancels the record. |
Start with ~all, confirm that all your real mail passes, then decide whether to tighten to -all. Both are valid; receivers differ in how strictly they treat each.
Ready-made examples
Replace the placeholders with your own. The provider names below were checked against live DNS on 8 November 2026 and each publishes an SPF record, but providers can change them, so always copy the include from your provider's current setup page. Then run the tool above to count the lookups.
Only Google Workspace
v=spf1 include:_spf.google.com ~all
Only Microsoft 365
v=spf1 include:spf.protection.outlook.com ~all
Google Workspace plus a newsletter service (Mailchimp)
v=spf1 include:_spf.google.com include:servers.mcsv.net ~all
Your own server or a typical cPanel host
v=spf1 +a +mx ip4:203.0.113.10 ~all
Use your server's real address, and only keep a and mx if they really are the sending machines.
No SPF record
Publish this at the root of the domain as a TXT record, with your provider's include in place of the example:
v=spf1 include:_spf.example.com ~all
A domain that never sends email
v=spf1 -all
Publish it on parked domains and on subdomains that send nothing. It tells receivers to reject anything claiming to come from there, which stops them being used for forgery.
Common provider includes
| Provider | Include |
|---|---|
| Google Workspace | include:_spf.google.com |
| Microsoft 365 | include:spf.protection.outlook.com |
| Amazon SES | include:amazonses.com |
| SendGrid | include:sendgrid.net |
| Mailgun | include:mailgun.org (this brings two more includes of its own) |
| Mailchimp | include:servers.mcsv.net |
| Postmark | include:spf.mtasv.net |
| Brevo | include:spf.brevo.com |
| Zoho Mail | include:zoho.com (several more includes inside; regional accounts use other names) |
| Proton Mail | include:_spf.protonmail.ch |
| Fastmail | include:spf.messagingengine.com |
| GoDaddy | include:secureserver.net |
Mistakes and what they look like
| What you see | Likely cause | Fix |
|---|---|---|
| permerror, “too many DNS lookups” | More than 10 lookups across your includes. | See “If you are over 10 lookups” above. |
| permerror, “multiple SPF records” | You added a second record when you added a service. | Merge into one: one v=spf1, all includes, one ending. |
| softfail or fail for mail you really sent | That service is not in your record. | Add its include (or its ip4), then re-test. |
| SPF passes in a checker but mail still goes to spam | SPF is only one signal. Or the service uses its own bounce domain, so the check never looks at your record. | Set up DKIM, and the service's “authenticated domain” or custom return path. Add DMARC. |
| Record not found | It is on the wrong name (a subdomain, or www), the quotes are wrong, or DNS has not updated yet. | Publish it as a TXT record at the exact domain mail comes from, and wait for the TTL. |
| Record ignored | A typo such as v=spf 1, a space inside a term, or spf2.0 at the start. | It must begin exactly with v=spf1. |
| Mail from a subdomain fails | SPF is not inherited. Each name mail comes from needs its own record. | Publish a record on the subdomain too. |
| Includes that suddenly break | The included domain lost its SPF record or has a typo. | Check the include name against the provider's instructions. A void include counts against the limit. |
+all or ?all at the end | Copied from an old guide, or “to make it work”. | Replace with ~all, then list the missing sender properly. |
Forwarding and mailing lists
When a message is forwarded, the forwarder's server sends it, and that server is not in your record. So SPF can fail on a perfectly legitimate message. This is normal and cannot be fixed with SPF alone. DKIM survives forwarding when the message is not changed, which is why modern setups rely on SPF and DKIM together, and why DMARC passes if either one lines up with your From address. Some forwarders also rewrite the sender (SRS) to keep SPF working. A strict -all combined with a strict DMARC policy is the setup most likely to bounce forwarded mail.
Subdomains
SPF is not inherited. A record on example.com does nothing for mail from news.example.com. Give each name that sends mail its own record, and give names that send nothing v=spf1 -all. A wildcard record (*.example.com) can cover non-sending subdomains, but a wildcard only applies to names that have no records of their own, so check it behaves as you expect.
Test it
- Use the tool at the top of this page, or the email check, to read the record and count lookups.
- Send a message from each service you use to a Gmail address. Open it, choose “Show original” and look for the line
spf=pass. If you seespf=softfailorspf=fail, the service is missing from your record. - Look at the domain named next to it (
smtp.mailfrom=). That is the domain whose record was checked. If it is the provider's domain and not yours, the provider uses its own bounce domain; set up its custom return path so SPF lines up with your domain. - On the command line,
dig +short TXT example.comshows the record exactly as receivers see it.
Common questions
Do I need SPF if I have DKIM?
Google requires all senders to set up SPF or DKIM, and senders of more than 5,000 messages a day to Gmail users to have SPF, DKIM and DMARC. In practice, publish all three.
Why does a checker say pass but Gmail says fail?
Usually because the real envelope sender is a different domain than the one you checked (a provider's bounce domain), because the message was forwarded, or because the record is fine alone but over the lookup limit once all the includes are counted.
Include or redirect?
include adds another list to yours and carries on. redirect hands the decision to another domain's record entirely and is used instead of all. For most people, include is the one you want.
Should I list the provider's IP addresses myself?
No. Use their include, so their changes reach you automatically. Fixed addresses go stale without warning.
How long does a change take?
As long as the record's TTL, often from a few minutes to a few hours. Receivers that cached the old record keep using it until it expires.
Sources
- RFC 7208: Sender Policy Framework (the terms, the 10-lookup and void-lookup limits, record size, one record per domain, results)
- Google: email sender guidelines (who must have SPF, DKIM and DMARC)