What is an SPF record?
An SPF record is a DNS TXT record that lists the servers authorized to send email for a domain. SPF has no record type of its own. It is published only as TXT, and the dedicated SPF type is discontinued. The record is one text string in a single TXT record, and a name must not have multiple SPF records.
example.com. IN TXT "v=spf1 +mx a:colo.example.com/28 -all"
To look up a record, use the SPF checker or the TXT record lookup.
SPF record syntax and example
Annotated example
v=spf1 +mx a:colo.example.com/28 -all
v=spf1: the version.+mx: a directive.a:colo.example.com/28: a directive with an implied+.-all: the closing hard-fail directive.
Mechanisms listed after all must be ignored.
For a Microsoft 365-only domain, the record is:
example.com. IN TXT "v=spf1 include:spf.protection.outlook.com -all"
Most Microsoft 365 organizations need this include. Other email services often need an additional include: value, so check your provider's documentation. Create the record at your domain registrar, because Microsoft 365 has no SPF TXT configuration.
Mechanisms and qualifiers quick reference
| Term | DNS lookups |
|---|---|
include, a, mx, exists, redirect |
1 each |
ip4, ip6, all |
none |
| Qualifier | Meaning |
|---|---|
-all |
hard fail |
~all |
soft fail |
?all |
neutral |
With no qualifier written, + is implied.
-all, ~all and ?all
With -all, unlisted sources are not authorized and messages should be rejected. The outcome depends on the receiving system, and messages are typically discarded. Microsoft recommends -all for Microsoft 365 domains because DKIM and DMARC are also recommended. DMARC treats -all and ~all as SPF failures. However, its policy is effectively ignored for ~all failures when the message has no DKIM signature. ?all suggests no specific action for unidentified sources. It is meant for testing, not production.
Limits and common SPF errors
Only one SPF record per domain
Do not publish one record per email service. Merge them.
; Invalid: two SPF records
example.com. IN TXT "v=spf1 include:mail1.example.net -all"
example.com. IN TXT "v=spf1 include:mail2.example.org -all"
; Valid: one merged record
example.com. IN TXT "v=spf1 include:mail1.example.net include:mail2.example.org -all"
The 10 lookup limit and PermError
SPF evaluation is limited to 10 DNS-querying terms. Going over produces a permerror. Receivers may reject or flag such mail. Some destination systems reject it with a non-delivery report.
Counting include: statements alone can undercount. Each include needs at least one lookup, more if nested. An include pointing to a record with three more includes adds four lookups.
example.com. IN TXT "v=spf1 ip4:203.0.113.0/24 include:spf.protection.outlook.com -all"
Here ip4 and all cost nothing. The include costs at least one lookup, plus any nested ones. To fix an over-limit record, remove unnecessary entries.
Other faults also end in permerror:
- A syntax error anywhere in the record.
- An
include:domain that doesn't resolve or has no SPF record. Messages might be rejected.
A permerror means the published records could not be correctly interpreted, and the DNS operator must fix them. Use the SPF checker to count lookups and find the fault.
SPF, DKIM and DMARC
SPF alone is not enough. DKIM and DMARC should also be configured. SPF checks the MAIL FROM and HELO identities, not the visible From: header, so a sender can pass SPF with their own domain. Check your setup with the DKIM checker and DMARC checker. The email security guide has more.
References
- RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1, IETF, sections 2.6.7, 3, 3.1, 3.2, 4.6, 4.6.4, 5.1, 11.2
- Set up SPF to identify valid email sources for your Microsoft 365 domain - Microsoft Defender for Office 365 | Microsoft Learn, learn.microsoft.com
- DNS lookup limit ยท Cloudflare DMARC Management docs, developers.cloudflare.com