An SPF record is one line of text in your domain's DNS. It lists the servers that may send mail using your domain name. The standard says an SPF record "declares which hosts are, and are not, authorized" to use a domain name for the mail identities it checks.1
Reading a record from left to right
Here's the example record from the standard:1
v=spf1 +mx a:colo.example.com/28 -all1
The standard explains it this way: the record has a version of "spf1" and three directives.1 The directives are the parts after the version.
- v=spf1 says this text is an SPF record. A record that doesn't start with the version tag isn't treated as one.1
- mx means servers named in the domain's mail exchanger records are allowed.
- a:colo.example.com/28 allows addresses found by looking up a named host, with a "/28" size on the end.1
- all matches everything else, so it always comes last.
Each directive can carry a prefix called a qualifier. It's a single symbol that says what result to give when that directive matches. A plus means pass, a minus means fail, a tilde means softfail and a question mark means neutral. If you leave the symbol off, it defaults to plus.1
What the results mean
A "pass" says the sending server is authorised to use the domain. A "fail" says it isn't.1
"Softfail" is weaker. The standard calls it a weak statement that the host is probably not authorised, from a domain that hasn't published a stronger policy.1 That's why a record ending in a tilde followed by "all" is a gentler setting than one ending in a minus followed by "all".
There's also "permerror". It means the published records couldn't be correctly interpreted, and the standard says that needs the DNS operator to step in.1
Where the list lives
An SPF record is published as a TXT record, which is a general text entry in DNS, at the domain's own name.1 The standard also says multiple SPF records aren't permitted for the same owner name.1 If a domain has two lines starting with the version tag, that's a mistake to fix.
Many mail services give you an include directive to paste in. It tells receivers to also read another domain's list. That's how a domain can say "my newsletter tool may send for me" without copying that tool's server addresses.
The limit on lookups
Some directives, such as include, a and mx, make the receiver run extra DNS queries. The standard limits the total of those to 10, and exceeding it must produce a permerror.1 Stacking many includes from many services is the usual way to hit that limit.
What SPF can't do alone
SPF checks the sending server, not the message. One reference notes that plain forwarding can break SPF. Forwarded mail may be rejected or bounced when all of these hold. The domain publishes an SPF FAIL policy. The forwarder does not rewrite the Return-Path. The next hop does not allowlist the forwarder, and that hop checks SPF. The same reference says mailing lists, which rewrite the Return-Path, are not affected in the same way.2
SPF also doesn't check the From address that readers see. That gap is why DMARC exists. See What SPF, DKIM and DMARC are for how the pieces fit, and How DKIM signing works for the check that does travel with the message.
Where the facts come from
- RFC 7208: Sender Policy Framework (SPF), IETF
- Sender Policy Framework, Wikipedia