What is SPF, and how does an SPF record work?
SPF (Sender Policy Framework) is a DNS TXT record that lists the servers allowed to send mail for your domain. Receivers compare the connecting server's IP address with the record for the envelope sender (MAIL FROM) domain and get pass, fail, softfail or another result. SPF doesn't check the visible From address; DMARC does that.
On this page 10 sections
SPF is the oldest of the three email authentication records and the one most domains already have. It answers one narrow question: is this server allowed to send mail using this domain in the envelope? This guide explains how receivers run that check, where it stops being useful, and how to publish a record that works. It's also the hub for our SPF guides.
What is an SPF record?
SPF stands for Sender Policy Framework. It is defined in RFC 7208, a Standards Track document from April 2014 that replaced the experimental RFC 4408. In the RFC's words, it lets domain owners "authorize hosts to use their domain names in the 'MAIL FROM' or 'HELO' identities."
The record is a single DNS TXT record on the domain itself:
example.com. 3600 IN TXT "v=spf1 include:spf.protection.outlook.com ip4:203.0.113.10 -all"
v=spf1marks the TXT record as SPF. Receivers discard TXT records that don't start with exactly this.include:andip4:are mechanisms: each one describes servers that may send.-allis the catch-all at the end. It sets the result for every server not listed.
RFC 7208 section 3.1 says SPF records "MUST be published as a DNS TXT (type 16) Resource Record" only. The separate SPF record type from the experimental phase is discontinued. A domain may publish only one SPF record; two or more give PermError (section 4.5).
How does a receiver check SPF?
SPF normally runs during the SMTP conversation, before the message body arrives; RFC 7208 says the check "SHOULD be performed" then. The receiving server knows three things at that point: the IP address that connected, the name the server gave in HELO/EHLO, and the envelope sender in MAIL FROM.
- Optionally check the HELO name. RFC 7208 section 2.3 says it is "RECOMMENDED" to check the HELO identity as well. A conclusive HELO result can save the more complex MAIL FROM check.
- Check the MAIL FROM domain. Verifiers "MUST check the 'MAIL FROM' identity" if a HELO check wasn't done or wasn't conclusive (section 2.4). For bounces, which have an empty MAIL FROM, SPF uses
postmaster@plus the HELO name instead. - Fetch the TXT record for that domain and keep the one that starts with
v=spf1. - Evaluate mechanisms left to right. The first one that matches the connecting IP decides the result, using its qualifier. Nothing after it is read.
- Record the result, usually in an
Authentication-ResultsorReceived-SPFheader, and apply local policy.
The function returns one of seven results (section 2.6):
| Result | What it means | Typical cause |
|---|---|---|
pass |
The IP is authorized | The server is listed |
fail |
The IP is explicitly not authorized | Unlisted server, record ends -all |
softfail |
Probably not authorized | Unlisted server, record ends ~all |
neutral |
The domain makes no statement | Record ends ?all |
none |
No SPF record, or no usable domain | No v=spf1 record published |
temperror |
A temporary DNS problem | Timeout; retrying may work |
permerror |
The record can't be interpreted | Two records, syntax error, too many lookups |
RFC 7208 deliberately leaves handling to the receiver: "the protocol establishes no normative requirements for handling any particular result." Microsoft puts it plainly for -all and ~all: "What actually happens to the message depends on the destination email system."
What are SPF mechanisms and qualifiers?
Mechanisms match the sending IP. The common ones are ip4, ip6, include, a, mx and all. Each can carry a qualifier: + pass (the default), - fail, ~ softfail and ? neutral. Two modifiers, redirect= and exp=, round out the syntax.
| Mechanism | Matches when | Counts toward the lookup limit? |
|---|---|---|
ip4, ip6 |
The IP is in the listed address or range | No |
include:domain |
The other domain's SPF check passes for this IP | Yes |
a, mx |
The IP belongs to the named host or MX hosts | Yes |
exists, ptr |
Special cases; ptr shouldn't be used |
Yes |
all |
Always; goes last | No |
Every mechanism, with copy-ready examples and the mistakes we see most, is covered in SPF record syntax and examples.
What are the SPF lookup limits?
SPF can trigger many DNS queries, so RFC 7208 caps them. Section 4.6.4 sets three limits:
- 10 DNS-querying terms. The
include,a,mx,ptrandexistsmechanisms and theredirectmodifier count, including those inside records you include. Implementations "MUST limit the total number of those terms to 10", and going over "MUST return 'permerror'." - 2 void lookups. A lookup that returns no records, or a domain that doesn't exist, is a "void lookup". Implementations "SHOULD limit 'void lookups' to two", and exceeding the limit produces PermError. An
includethat points at a retired vendor domain is the usual cause. - 10 address records per
mxorptrterm. Anmxmechanism whose hosts resolve to more than 10 A or AAAA lookups returns PermError.
ip4, ip6 and all don't count. Microsoft notes that fewer than 10 include statements "doesn't guarantee fewer than 10 DNS lookups", because includes can nest (Microsoft Learn).
This limit catches large organizations too. In our October 2026 scan of the Tranco top 1,000 domains, 22 domains published an SPF record over the 10-lookup limit and 4 published more than one SPF record. Our guide to SPF PermError: too many DNS lookups shows how to count and cut lookups.
What doesn't SPF do?
SPF is useful but narrow. Know its blind spots before you rely on it.
It doesn't check the From address
SPF authenticates the MAIL FROM domain (and optionally HELO). The From: line people read in their mail client is a different header and can name any domain. A spammer can pass SPF for attacker.example while showing your domain in From. Linking the two is DMARC's job.
It breaks when mail is forwarded
When a message is forwarded, it arrives from the forwarder's IP, which isn't in your record. RFC 9989 section 7.4 says such mail "will most likely fail SPF checks" unless the forwarder rewrites the MAIL FROM address, while "DKIM signatures will generally remain valid." Appendix D of RFC 7208 describes the rewriting workarounds. Our guide to why forwarding breaks SPF and DMARC covers SRS and ARC.
It doesn't cover subdomains
SPF is checked for the exact domain in MAIL FROM. news.example.com needs its own record; it doesn't inherit example.com's. Microsoft says each subdomain that sends mail "requires its own SPF TXT record."
It says nothing about content
A message from an authorized server can still be spam or phishing. SPF proves only where the message came from, not whether it's wanted.
How does SPF work with DMARC?
RFC 9989, the current DMARC standard, uses SPF as one of its two inputs. It is explicit about which identity: "DMARC relies solely on SPF validation of the MAIL FROM identity." HELO results don't count.
An SPF pass helps DMARC only when the MAIL FROM domain aligns with the From domain. Under the default relaxed mode, bounce.example.com aligns with example.com; mailer-vendor.net doesn't. RFC 9989 explains why alignment is needed: "any Domain Owner, even a bad actor, can publish an SPF record for its domain and send an email that will obtain an SPF 'pass' result."
This is the most common surprise with third-party senders. Many newsletter, CRM and helpdesk tools use their own bounce domain by default. SPF passes, but for their domain, so it doesn't count toward your DMARC result. The fix is a custom return-path (often called a custom MAIL FROM or bounce domain) on a subdomain of yours, or aligned DKIM. Our guide to why DMARC fails walks through the cases.
To DMARC, fail, softfail, neutral, none and permerror are all the same: no aligned SPF pass. Then DKIM has to carry the message. See what DMARC is and how it works, and SPF vs DKIM vs DMARC for what each record proves.
Should an SPF record end in ~all or -all?
Both are defensible for a sending domain, and sources disagree:
| Source | Advice for domains that send mail |
|---|---|
| M3AAWG | "SPF records should end in ~all" |
| "Google recommends you use ~all in your SPF record" | |
| Microsoft | Recommends -all for Microsoft 365 domains that also use DKIM and DMARC |
The reason for caution is in RFC 9989 section 7.1: some receivers check SPF early, so a -all failure "could cause a message to be rejected early in the SMTP transaction, before any DMARC processing takes place", even when aligned DKIM would have passed it.
A sensible default: use ~all while you're still finding all your senders, and consider -all once DKIM is on every service and DMARC reports are clean. For a domain that never sends mail, publish v=spf1 -all; Microsoft and M3AAWG both recommend that for parked domains. Never use +all, and don't leave ?all in production. The full comparison is in SPF softfail vs hardfail.
How do I create an SPF record?
- List every service that sends as your domain: your mailbox platform, website and forms, CRM, helpdesk, invoicing and newsletter tools. Google's sender guidelines require SPF or DKIM from everyone sending to Gmail.
- Get each provider's documented value. Our SPF records by email provider pages list the exact include for common services, such as Microsoft 365 and Google Workspace, with their measured lookup cost.
- Move bulk senders to a subdomain where you can. Microsoft recommends this for services you don't directly control, and the subdomain gets its own 10-lookup budget.
- Build one record. The SPF Record Generator assembles it from your services and counts lookups.
- Publish or edit it at your DNS host. Replace the existing record; never add a second
v=spf1record. - Check it with the SPF Checker for syntax, lookup count and the
allending. - Test real mail. Send from each service to an outside mailbox and look for
spf=passin the headers, using the Email Header Analyzer. - Add DKIM and DMARC. SPF alone doesn't protect the From address.
Our SPF guides
| If you need to... | Read |
|---|---|
| Write or fix a record, term by term | SPF record syntax and examples |
| Fix PermError from too many lookups | SPF too many DNS lookups |
Choose between ~all and -all |
SPF softfail vs hardfail |
| Find the exact include for a provider | SPF records by email provider |
| Understand forwarding failures | Why forwarding breaks SPF and DMARC |
| Compare SPF with DKIM and DMARC | SPF vs DKIM vs DMARC |
| Lock down domains you don't send from | Protect parked domains from spoofing |
Next steps
- Run your domain through the SPF Checker to see your record, its lookup count and its
allending. - If anything is missing or broken, rebuild the record with the SPF Record Generator and replace the old one.
- Publish
v=spf1 -allon every domain you own that doesn't send mail. - Set up DKIM on each sending service, then publish DMARC; start with what DMARC is.
- Get the whole picture at once with the Email Health Check. If you'd like to hear when someone changes your SPF record, iBlockSpam domain monitoring sends drift alerts.
SPF records tend to break when someone adds a service months later. The Free Domain Watch checks your public SPF, MX, DMARC and MTA-STS records weekly and emails you when one changes; it needs no account.
Browse our other SPF, DKIM and DMARC guides.
Frequently asked questions
What does SPF stand for in email?
Sender Policy Framework. It's defined in RFC 7208, published in April 2014, which replaced the earlier experimental RFC 4408. The framework lets a domain owner publish, in DNS, which servers may use the domain in the SMTP MAIL FROM and HELO identities, so receivers can check each connecting server against that list.
Does SPF check the From address that people see?
No. SPF checks the envelope sender, the MAIL FROM address used during the SMTP conversation, which often appears as Return-Path. The From line in the mail client can be a different domain entirely. DMARC closes that gap by requiring the SPF-checked domain to align with the visible From domain.
What happens to an email that fails SPF?
It depends on the receiver. RFC 7208 sets no required handling: a receiver may reject a fail, mark it, or simply record the result and let DMARC, DKIM and reputation decide. A softfail should not be rejected on that result alone. A PermError usually means the record itself is broken.
How many SPF records can a domain have?
One. RFC 7208 says a domain must not publish more than one record starting with v=spf1, and receivers return PermError if they find two. Merge every sending service into a single record. Each subdomain that sends mail needs its own record, because SPF is checked for the exact domain.
Is SPF enough to stop spoofing of my domain?
No. SPF only protects the envelope sender, and an attacker can pass SPF with their own domain while showing yours in From. You need DKIM and a DMARC policy of quarantine or reject to stop exact-domain spoofing, plus inbound filtering for lookalike domains, which SPF can't touch.
Sources
- RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email
- RFC 9989: Domain-Based Message Authentication, Reporting, and Conformance (DMARC)
- Microsoft Learn: Set up SPF to identify valid email sources for your Microsoft 365 domain
- Google Workspace Admin Help: Set up SPF
- M3AAWG Email Authentication Recommended Best Practices (September 2020)
- Gmail Help: Email sender guidelines
See how your domain measures up
Run a free Email Health Check: MX, SPF, DKIM, DMARC and transport security in one scan, with the raw records shown. No sign-up.
Keep reading
SPF record syntax and examples
SPF record syntax explained: mechanisms, qualifiers and modifiers, with copy-ready examples for Microsoft 365, Google Workspace, subdomains and parked domains.
9 min read SPF, DKIM & DMARCSPF softfail vs hardfail: should you use ~all or -all?
What ~all, -all and ?all mean in SPF, what receivers really do with each, how DMARC changes the choice, and which one to use for sending and parked domains.
8 min read SPF, DKIM & DMARCHow to fix SPF PermError: too many DNS lookups
Why SPF breaks at 10 DNS lookups, how to count them, and step-by-step fixes for Microsoft 365 and Google Workspace domains with many senders.
8 min read