What is SPF (Sender Policy Framework)?
SPF (Sender Policy Framework): An email authentication method in which a domain publishes a DNS TXT record listing the hosts allowed to send mail using that domain as the envelope sender.
Last reviewed:
SPF (Sender Policy Framework) is an email authentication protocol that lets a domain owner publish, in DNS, which hosts are authorized to send mail using that domain. A receiving server compares the connecting IP address with that list and returns a result such as pass, fail, or softfail.
How it works
SPF version 1 is specified in RFC 7208 (April 2014), which obsoleted RFC 4408. A domain publishes one TXT record that begins with v=spf1, followed by mechanisms such as ip4, ip6, a, mx, include, and a final all. Each mechanism can carry a qualifier: + (pass, the default), - (fail), ~ (softfail), or ? (neutral).
The receiver checks the domain used in the SMTP MAIL FROM command (the envelope sender, or return path) and, as RFC 7208 recommends, the HELO identity. SPF does not authenticate the visible From: header on its own; DMARC creates that link by requiring the SPF-authenticated domain to align with the From domain.
example.com. 3600 IN TXT "v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.25 include:_spf.example.net ~all"
This record authorizes the 192.0.2.0/24 range, one additional address, and any hosts authorized by the SPF record at _spf.example.net. All other sources receive softfail.
RFC 7208 sets two processing limits. The include, a, mx, ptr, and exists mechanisms and the redirect modifier may together trigger no more than 10 DNS lookups; exceeding the limit returns permerror. Implementations should also limit "void lookups" (queries that return no records) to two.
Why it matters for marketers
Since February 1, 2024, Gmail has required all senders to use SPF or DKIM, and senders of 5,000 or more messages per day to personal Gmail accounts to use both. Yahoo applies the same split between all senders and bulk senders. When an email service provider sends on a brand's behalf, the brand usually has to authorize the provider in its SPF record or delegate a return-path subdomain, so that SPF passes for a domain that aligns with the From address.
Common mistakes
- Publishing two or more
v=spf1records for the same name, which RFC 7208 treats aspermerror. - Exceeding the 10-lookup limit by stacking
include:statements from several vendors. - Using the
ptrmechanism, which RFC 7208 says should not be published. - Ending the record with
+all, which authorizes every host on the internet. - Expecting SPF to survive forwarding. RFC 7208 notes that evaluation is based on the IP address of the last sending server, so forwarded mail often fails unless the forwarder rewrites
MAIL FROM. - Splitting a long policy into several TXT records instead of several strings within one record; strings in one record are joined without spaces.
Related terms
- DKIM (DomainKeys Identified Mail)
- DMARC (Domain-based Message Authentication, Reporting, and Conformance)
- Bulk sender requirements
- Email deliverability