SPF record: what it is and how to set one up

Last updated

The short answer

An SPF record is a single line of text in your domain's DNS that lists the servers allowed to send email for your domain. Receiving mail servers check it to tell your real email from forgeries. You should have exactly one, starting v=spf1, listing your email provider and every service that sends as you, and ending ~all or -all. Gmail and Yahoo expect every sender to have SPF or DKIM, and bulk senders to have both.

Reading an SPF record, part by part

A typical record for a small business:

v=spf1 include:_spf.google.com include:servers.newsletter-tool.example ip4:203.0.113.10 ~all
PartWhat it means
v=spf1"This is an SPF record." Must come first.
include:"Also allow whatever this service lists." Your email provider and each sending tool give you one.
ip4: / ip6:Allow one server's address, or a range, directly.
a / mxAllow the servers your domain's own A or MX records point to.
~all"Anything else is probably not us" (a soft fail).
-all"Anything else is not us" (a fail).
+all"Anyone may send as us." Never use it: it switches protection off.

RFC 7208, the SPF standard, also defines ptr, and tells domains not to use it.

~all or -all?

Both tell receivers that unlisted servers aren't yours; -all says it more firmly. Once you have a DMARC record, DMARC's policy decides what happens to failing mail, so the ending matters less. A sensible path: use ~all while you are still finding every service that sends as you, and move to -all when your DMARC reports show nothing legitimate failing. See the DMARC record explained.

The ten-lookup limit

Checking an SPF record may need no more than ten DNS lookups (RFC 7208). Every include:, a, mx and redirect= counts, and so do the includes inside each include. Receivers count them as they work through the record from left to right, and stop at the first match. Go over ten and the check returns an error. Mail from services listed early may still pass, but mail from services listed later fails first, and some receivers reject the whole record. After any change, send a test message from every service that sends as you.

Common mistakes

What Gmail and Yahoo require

Since February 2024, Google and Yahoo require every sender to set up SPF or DKIM. Bulk senders (Google's threshold is more than 5,000 messages a day to Gmail) need SPF and DKIM, a DMARC record, a From address that aligns with them, and one-click unsubscribe for marketing mail. Mail that misses these is more likely to be rejected or sent to spam.

How to set one up

  1. List every service that sends email as your domain: your email provider, newsletter tool, invoicing or booking system, and your website's contact form.
  2. Follow each one's own set-up instructions. Many give you an include for your SPF record. Some, such as Amazon SES, send with their own return-path domain or a subdomain you set up for them, and need no include in your main record. Add an include only when the service asks for one.
  3. Add (or edit) one TXT record on your domain: v=spf1 include:… include:… ~all. Don't copy the .example include or the sample address from the record above into your DNS: they are placeholders.
  4. Set up DKIM with each service too, so it signs with your domain, and add a DMARC record. The SPF, DKIM and DMARC guide has the exact records for Google Workspace and Microsoft 365.

How to check yours

Checklist

Questions people ask

Where do I add an SPF record?
In the DNS settings wherever your domain's DNS is managed: your domain registrar, your host, or a service such as Cloudflare. It is a TXT record on the domain itself, often entered as @.
Can I have two SPF records?
No. RFC 7208 allows one. Two SPF records is an error that can make SPF fail for all your mail, so merge them into one record with every include: in it.
Does SPF stop people faking my email address on its own?
No. SPF checks the hidden return address of a message, not the From address people see. DMARC is what ties SPF and DKIM to the visible From address and tells receivers what to do with fakes.
Should my SPF record end in ~all or -all?
Either works once you have DMARC, which then decides what happens to failing mail. Use -all when you're sure every service that sends as you is listed; ~all is the gentler choice while you're still checking. Never use +all.
Why did my SPF record stop working after I added a new email tool?
Often because the record now needs more than ten DNS lookups. The check then returns an error, first for mail from the services listed last, and some receivers reject the whole record. Remove services you no longer use, or send marketing email from a subdomain with its own SPF record.

What the free scan checks for this

These are the FocalScore checks that cover this guide's subject. Each one in your report says what it found, shows the evidence and gives the fix.

Sources

Last checked . Documentation, settings and rules change; if one of these pages now says something different, it is right and this guide is out of date. Tell us at info@focalscore.com.

  1. RFC 7208: Sender Policy Framework (SPF)
  2. Google Workspace Admin Help: Email sender guidelines
  3. Yahoo Sender Hub: Sender best practices