An SPF record is a TXT record that lists the servers allowed to send mail for a domain. Receivers read it left to right and stop at the first term that matches the sending IP. This page covers the format, each term, and the mistakes that make a record fail. The rules are in RFC 7208.
The format
v=spf1 [mechanisms] [modifiers] allA record starts with exactly v=spf1, then terms separated by single spaces. A typical record:
v=spf1 ip4:192.0.2.10 include:_spf.google.com ~allThat reads: pass mail from 192.0.2.10, pass mail from any server Google lists, and soft fail everything else.
Mechanisms
ip4:192.0.2.10orip4:192.0.2.0/24matches one IPv4 address or a range. No DNS lookup.ip6:2001:db8::/32does the same for IPv6. No DNS lookup.include:_spf.example.comchecks another domain's SPF record and matches if that record passes. This is how you authorize a provider. One lookup, plus the lookups inside that record.amatches the domain's own A or AAAA address.a:host.example.comuses another name. One lookup.mxmatches the servers in the domain's MX records. One lookup toward the limit, and each MX host needs an address lookup of its own.exists:matches if a name resolves. It is mostly used with macros. One lookup.ptrmatches on reverse DNS. The RFC says not to use it: it is slow and receivers may skip it.allmatches everything. It goes last.
Qualifiers
A qualifier in front of a mechanism sets the result when it matches. With no qualifier the result is pass.
+pass, the default.+alllets anyone send as you, so never use it.-fail.-allsays nothing else may send.~softfail.~allsays other senders are probably not you. Most domains start here.?neutral.?allmakes no claim either way.
Modifiers
redirect=_spf.example.com hands the whole check to another domain's record, and is used when several domains share one policy. It only applies when the record has no all. exp= names a TXT record with an explanation for rejected mail. Few receivers show it.
Example records
Only your own server sends:
v=spf1 ip4:203.0.113.5 -allGoogle Workspace and one other provider:
v=spf1 include:_spf.google.com include:spf.example-provider.com ~allA domain that never sends mail:
v=spf1 -allLimits
- One SPF record per DNS name. A second
v=spf1record is a permerror: see multiple SPF records. - At most 10 lookups from
include,a,mx,ptr,existsandredirectin one check. See SPF too many DNS lookups. - At most two lookups that return nothing. A typo in an include host is the usual cause.
- One TXT string holds 255 characters. A longer record is split into several quoted strings, which receivers join with no space between them. Put the space inside a string, not at the join.
Mistakes that break a record
- A version other than
v=spf1, such asv=spf2orspf1, or a space around the equals sign. - A colon left out or doubled, as in
include_spf.google.comorip4::192.0.2.1. - Terms after
all. Receivers stop atall, so anything after it never counts. - An IP address written into an include, as in
include:192.0.2.1. Useip4:. - Curly quotes pasted from a document into the DNS value.
Paste a record into the draft test on the SPF checker to check the syntax and lookup count before you publish it.
Next steps
- Quickstart for the full first-send walkthrough.
- Verify webhooks to learn when an email is delivered or bounces.
- Pricing: 3,000 emails a month free, no card.