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| Part | What 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 / mx | Allow 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.
- Remove services you no longer use.
- Send newsletters or marketing email from a subdomain (such as
news.yoursite.com) with its own SPF record. - Be wary of "flattening" (replacing includes with lists of addresses): when a provider changes its servers, a flattened record silently goes out of date.
Common mistakes
- Two SPF records. One is allowed; merge them.
- A service left out: often the website's contact form, which may send through your web host rather than your email provider. Add the host's include, or make the form send through your provider.
+allor?all, which protect nothing.- Over ten lookups, as above.
- Thinking SPF protects the From address. It checks the hidden return address. DMARC is what protects the address people see.
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
- List every service that sends email as your domain: your email provider, newsletter tool, invoicing or booking system, and your website's contact form.
- 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.
- Add (or edit) one TXT record on your domain:
v=spf1 include:… include:… ~all. Don't copy the.exampleinclude or the sample address from the record above into your DNS: they are placeholders. - 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
- Run the free scan: it shows the SPF record it found and what it is missing.
- Send a message from your domain to a personal Gmail address, open it and choose Show original: it shows SPF as PASS or FAIL.
- On a computer,
nslookup -type=txt yoursite.comlists your TXT records; there should be one startingv=spf1.
Checklist
- Exactly one SPF record, starting v=spf1.
- Every service that sends as you is covered, the contact form too: by an include, or by its own return-path domain.
- It ends in ~all or -all, never +all.
- It needs no more than ten DNS lookups.
- DKIM and DMARC are set up alongside it.
- A test message to Gmail shows SPF: PASS.
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.
- SPF record
- DKIM / DMARC
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.
- RFC 7208: Sender Policy Framework (SPF)
- Google Workspace Admin Help: Email sender guidelines
- Yahoo Sender Hub: Sender best practices
More guides
- How to get your business recommended by ChatGPT and other AI assistants
- Why can't ChatGPT see my website? 5 reasons and how to fix them
- robots.txt for small businesses: what to allow, what to block
- What is IndexNow, and why does it matter for your website?
- The pages every small-business website needs
- How to turn more website visitors into enquiries
- Why your site is slow, and what to fix first
- How your business shows up in Google: titles, descriptions and headings
- One address for each page: www, https, canonical tags and redirects
- A sitemap for any site, including one built by hand
- Making your site usable by everyone
- Making your site work on a phone
- Security headers for a small business website: what to set, by platform
- Stop people sending email as your business: SPF, DKIM and DMARC
- Cookies and consent: what your site sets and when you need a banner
- How your links look when people share them
- Getting your business details right for Google Maps and AI assistants
- What is GEO (generative engine optimization)? A plain-English guide
- llms.txt: what it is, and does your business need one?
- AI crawler blocked? Fixing 403, 404 and 405 errors for GPTBot, ClaudeBot and PerplexityBot
- How to see if ChatGPT visits your website
- GEO vs SEO: what's the difference for a small business?
- AI SEO for small businesses: where to start
- Answer engine optimization (AEO), explained
- DMARC record: what it is and how to set one up
- DKIM record: what it is and how to set it up
- Why do my emails go to spam? How to check SPF, DKIM and DMARC
- Content Security Policy (CSP) for a small business website
- Website caching and CDNs: what they are and do you need one?
- security.txt: what it is and how to add one to your site
- What is DNSSEC, and should you turn it on?
- CAA record: what it is and how to set one up
- Largest Contentful Paint (LCP): why your page feels slow and how to fix it
- Local business schema: structured data for a small business, with a template
- Accessibility statement: what to write, with a template
- Trust badges and testimonials that help a website win customers
- Why isn't my website showing up on Google? How to get it there
- Google Business Profile: a checklist to make it match your website
- Custom 404 page: what a good one does, and the soft 404 trap
- Meta description length: how long should it be?
- Image alt text: what to write, with examples
- Broken links: how to find and fix them on your website
- Website audit checklist: a free check-up for a small business site
- Why does my website say 'Not secure'? How to fix it
- Is my website ADA compliant? An accessibility checklist for US small businesses
- Has my website been hacked? How to check, and what to do next
- Core Web Vitals explained: LCP, INP and CLS in plain English
- Interaction to Next Paint (INP): why your site feels slow to tap, and how to fix it
- Cumulative Layout Shift (CLS): why your page jumps while it loads, and how to stop it
- What should a small business privacy policy include? A checklist
- Contact form emails not arriving? Find where enquiries get lost
- Website monitoring: catch downtime, broken enquiries and expired certificates
- Moving or redesigning your website: a checklist so nothing gets lost
- How to audit a WordPress website: a checklist for owners
- Why isn't my business showing up on Google Maps?
- Does ChatGPT recommend your business? How to check, and how to fix what it gets wrong
- Why isn't my website getting customers? A three-question diagnosis
- How to get more Google reviews without breaking Google's rules
- Google Search Console for a small business: set it up and read the three reports that matter
- Who owns your domain and website? How to check, and how to get them back
- How to show up in Google AI Overviews and AI Mode: what Google's own guide asks for
- What is a good PageSpeed score? What the number means for a small business site
- How much should a small business website cost, and what to check before you pay the final invoice
- Is my website down, or is it just me? What to check, in order
- Is my SEO company actually doing anything? How to check, and how to spot a scam email
- Should I redesign my website or just fix it?
- Does your website still need an FAQ page now that Google's FAQ rich results are gone?