SPF (Sender Policy Framework, RFC 7208) lets you publish which servers are allowed to send email for your domain. Receivers compare the IP address of the connecting server with that list. It is one of the three pillars of email authentication, together with DKIM and DMARC.
What exactly does SPF check?
SPF checks the envelope sender - the address in the SMTP MAIL FROM command, which ends up in the Return-Path header. It does not check the From: address people see in their mail client. That is why SPF alone does not stop spoofing: the visible From is protected only when DMARC requires the SPF (or DKIM) domain to align with it.
SPF also breaks on plain forwarding: the forwarding server is not in your list. DKIM survives forwarding, so always use both.
The record
SPF is a single TXT record on the domain itself, starting with v=spf1:
example.com. TXT "v=spf1 ip4:203.0.113.10 include:_spf.google.com -all"
Mechanisms are evaluated from left to right; the first one that matches the sender's IP decides the result.
Mechanisms
ip4:/ip6:- a single address or a range, e.g.ip4:203.0.113.0/24. No DNS lookup needed.a- the IP addresses of the domain's A/AAAA record (your web server, if it also sends mail).mx- the IP addresses of the domain's MX servers. Useful only when the same servers both receive and send.include:- also allow everything allowed by another domain's SPF, typically your email provider (include:spf.protection.outlook.com,include:_spf.google.com,include:spf.seznam.cz...).exists:- advanced, used with macros.ptr- deprecated by RFC 7208: slow and unreliable. Do not use it.all- matches everything; always the last term and defines what happens to everyone else.redirect=- use another domain's SPF record entirely (only when there is noall).
-all, ~all, ?all and +all
Each mechanism can have a qualifier: + pass (default), - fail, ~ softfail, ? neutral.
-all(fail) - servers not listed are not authorized. Receivers may reject the message; many big providers instead feed the result into DMARC and spam scoring.~all(softfail) - not authorized, but accept and treat with suspicion. A safe choice while you are still finding all your senders, and perfectly fine long-term when you have DMARC withp=quarantineorp=reject.?all(neutral) - SPF says nothing. Gives no protection.+all- allows every server on the internet to send as you. Never use it.
The rules that break SPF most often
- Only one SPF record per domain. Two TXT records starting with
v=spf1cause a PermError - SPF fails for all your mail. Merge them into one. - Maximum 10 DNS lookups. Every
include,a,mx,existsandredirectcounts, including those inside included records. Over 10 means PermError. Remove unused includes or replace them withip4ranges. - Forgotten senders. Newsletter tools, CRM, invoicing systems, web forms - every service that sends as your domain must be included (or send with its own Return-Path domain and sign with DKIM for your domain).
- Domains that don't send mail should publish
v=spf1 -allso nobody can use them.
Examples
Microsoft 365 only:
v=spf1 include:spf.protection.outlook.com -all
Own mail server plus Google Workspace and a newsletter service:
v=spf1 ip4:203.0.113.10 include:_spf.google.com include:servers.mcsv.net ~all
A domain that never sends email:
v=spf1 -all
Check your record
Our SPF Lookup shows your record, counts the DNS lookups including nested includes and points out the mistakes above. To see how SPF actually performed for a real message, use the Email Deliverability Test or paste headers into the Header Analyzer.