What is an SPF record?
SPF (Sender Policy Framework) is a TXT record in your DNS that lists the servers allowed to send email for your domain. When a message arrives, the receiving server checks whether the server that sent it is on the list. Together with DKIM and DMARC it stops others from sending email that pretends to come from you, and it helps your own email reach the inbox.
How to use the generator
- Optional: enter your domain and press Load to start from your current record.
- Tick the services that send email for you: your mailbox provider (Google Workspace, Microsoft 365…), newsletter tools, your shop or help desk.
- Add the IP addresses of your own servers, if any.
- Choose what to do with email from other servers.
~allis the usual choice. - Copy the record and publish it as a TXT record on your domain (name
@), replacing any old SPF record.
Parts of an SPF record
| Part | Meaning | DNS lookups |
|---|---|---|
v=spf1 | Always first: marks the record as SPF. | 0 |
ip4:203.0.113.10 | An IPv4 address or network (/24) that may send. | 0 |
ip6:2001:db8::/32 | The same for IPv6. | 0 |
mx | The servers in your MX records may send. | 1 |
a | The server your domain points to may send. | 1 |
include:_spf.google.com | Everything allowed by another domain's SPF (a provider). | 1 + nested |
~all / -all | Always last: what to do with every other server (softfail / fail). | 0 |
The 10-lookup limit
To check SPF, receivers may make at most 10 DNS lookups. Each include, mx and a
uses one, and the includes of your providers often contain more includes. Go over 10 and the result is a
PermError: SPF fails for all your email, as if it were forged. The generator adds up the lookups of
each service for you. If you are close to the limit, remove services you no longer use, or replace includes with the
provider's IP ranges (keeping in mind that you will have to update them yourself).
Examples
Google Workspace only:
v=spf1 include:_spf.google.com ~all
Microsoft 365 + Mailchimp:
v=spf1 include:spf.protection.outlook.com include:servers.mcsv.net ~all
A domain that never sends email:
v=spf1 -all
After publishing, check the result with the SPF Checker, then protect the domain fully with a DMARC record.