SPF explained: what every part of the record does, and how to fix it

Last updated 8 November 2026

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

  1. A message arrives at a receiving mail server from some IP address.
  2. 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).
  3. It looks up that domain's TXT records and finds the one that starts with v=spf1.
  4. It reads the terms left to right. The first term that matches the sending IP address decides the result, and the rest are ignored.
  5. If nothing matches, the result is “neutral” (unless the record ends with a redirect=).
  6. The receiver combines that result with DKIM, DMARC and its own knowledge of your reputation. SPF alone rarely decides whether mail is delivered.
Important: SPF checks the envelope sender, not the visible From address. A scammer can pass SPF with their own domain while showing your address in From. DMARC is the part that ties the two together, which is why SPF on its own does not stop people forging your address.

The anatomy of a record

v=spf1  ip4:203.0.113.10  include:_spf.google.com  mx  ~all

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.

SymbolResultMeaning in practice
+ (or nothing)PassThis sender is allowed.
-FailThis sender is not allowed. Receivers usually reject the message or send it to spam, but each receiver decides for itself.
~SoftfailThis sender is probably not allowed. Mail is normally accepted but treated with suspicion.
?NeutralNo opinion. Treated almost as if there were no SPF record.

Mechanisms: who is allowed

TermIt matches when…DNS lookupsWatch out for
allAlways. It catches everything not matched before it.0Put it last. Terms after it are never read. +all allows the whole internet.
ip4:203.0.113.10
ip4:203.0.113.0/24
The sending IPv4 address equals the address, or falls in the range. /24 means 256 addresses.0The cheapest and most precise term. Make sure the range is really yours.
ip6:2001:db8::/32The same, for IPv6 addresses.0If your server sends over IPv6 and you only list IPv4, mail sent over IPv6 fails.
a
a:mail.example.com
a/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.1Handy when your website server also sends mail. Meaningless if you send through a provider.
mx
mx:other.com
The sending address is one of the domain's mail servers (its MX records).1Right 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.comThe other domain's SPF record says this sender is allowed (a “pass”).1 plus everything inside that recordThe 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.comA DNS lookup of that name finds any address. Macros such as %{i} insert the sender's IP into the name.1Used by some big providers to approve individual servers. Almost never needed in a hand-written record.
ptrThe sender's reverse DNS name ends in your domain.1The standard says it should not be published: it is slow and unreliable. Replace it with ip4 or include.

Modifiers: extra instructions

TermWhat it doesLookups
redirect=example.comIf 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.comNames a TXT record whose text is shown to people whose mail fails. Very rarely used.0 in normal use
anything else, such as foo=barUnknown 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

ResultMeaningUsual cause
passThe sender is allowed.Matched a term with + (or no symbol).
failNot allowed.Matched -, usually the -all at the end. A server you forgot to list.
softfailProbably not allowed.Matched ~all, so a sender is missing from the list or someone is forging your domain.
neutralNo opinion.Matched ?, or nothing matched and there is no all.
noneNo SPF record found.The record was never published, or is on the wrong name.
temperrorA temporary DNS problem.A DNS server was slow or unreachable. Usually clears on retry.
permerrorThe 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.

If you are over 10 lookups

  1. Remove what you do not use. Includes for tools nobody uses any more are the usual cause. Check what actually sends your mail first.
  2. Use a subdomain for each sending service. Send newsletters from news.example.com and give that name its own short SPF record, so the main domain's record stays small.
  3. 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.
  4. Avoid ptr, and be sparing with a and mx. Each costs a lookup that an ip4 would not.
  5. “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?

EndingWhat happens to mail from unlisted serversUse it when
-allFailed. 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).
~allSoftfailed. 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.
?allNeutral. Treated as if SPF were not there.Almost never. It gives no protection.
+all or allPassed. 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

ProviderInclude
Google Workspaceinclude:_spf.google.com
Microsoft 365include:spf.protection.outlook.com
Amazon SESinclude:amazonses.com
SendGridinclude:sendgrid.net
Mailguninclude:mailgun.org (this brings two more includes of its own)
Mailchimpinclude:servers.mcsv.net
Postmarkinclude:spf.mtasv.net
Brevoinclude:spf.brevo.com
Zoho Mailinclude:zoho.com (several more includes inside; regional accounts use other names)
Proton Mailinclude:_spf.protonmail.ch
Fastmailinclude:spf.messagingengine.com
GoDaddyinclude:secureserver.net

Mistakes and what they look like

What you seeLikely causeFix
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 sentThat 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 spamSPF 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 foundIt 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 ignoredA 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 failsSPF is not inherited. Each name mail comes from needs its own record.Publish a record on the subdomain too.
Includes that suddenly breakThe 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 endCopied 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

  1. Use the tool at the top of this page, or the email check, to read the record and count lookups.
  2. 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 see spf=softfail or spf=fail, the service is missing from your record.
  3. 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.
  4. On the command line, dig +short TXT example.com shows 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