Home / Guides / Authentication

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

How SPF tells receiving servers which systems may send for your domain, with syntax explained, provider examples and the mistakes that break it.

7 min read · Updated 27 October 2026 · By the dijitul team

An SPF record is a single line of text in your domain's DNS that lists the servers and services allowed to send email for that domain. When a message arrives, the receiving server looks up the record and checks whether the connecting server is on the list. Getting it right is one of the basic requirements for reaching the inbox at Gmail, Yahoo and Microsoft.

What SPF actually checks

SPF (Sender Policy Framework, defined in RFC 7208) checks the envelope sender: the address the sending server gives in the SMTP MAIL FROM command, which ends up in the Return-Path header. It does not look at the From address your recipient sees.

That distinction matters. When you send through a newsletter platform, the envelope sender is often the platform's own domain, so SPF passes for their domain, not yours. To make SPF count towards DMARC, the envelope domain has to align with your visible From domain. Many platforms let you set up a custom return-path (sometimes called a bounce domain) on a subdomain such as bounce.example.co.uk to achieve this.

Anatomy of an SPF record

An SPF record is a TXT record published on the domain itself (the root, shown as @ in most DNS panels). Here is a typical one for a business using Google Workspace plus a transactional email service:

example.co.uk.  3600  IN  TXT  "v=spf1 include:_spf.google.com include:sendgrid.net ip4:203.0.113.25 ~all"

Reading left to right:

  • v=spf1 identifies the record as SPF. It must come first.
  • Each following term is a mechanism, checked in order until one matches.
  • ~all at the end says what to do with anything that has not matched.

Mechanisms

MechanismWhat it matchesCosts a DNS lookup?
ip4:203.0.113.25A single IPv4 address or a range such as 203.0.113.0/24No
ip6:2001:db8::/32An IPv6 address or rangeNo
aThe IP addresses the domain's A/AAAA records point toYes
mxThe servers listed in the domain's MX recordsYes
include:domainWhatever that other domain's SPF record allowsYes, plus any lookups inside it
exists:domainPasses if the named domain resolves; used in advanced setupsYes
ptrReverse DNS match. Deprecated: do not use itYes
allEverything. Always goes lastNo

There is also the redirect= modifier, which hands the whole evaluation to another domain's record. It is useful when several domains share one policy, and it also counts as a lookup.

Qualifiers: ~all vs -all

Every mechanism can carry a qualifier prefix. If you leave it off, + (pass) is assumed. In practice the qualifier only matters on all:

  • -all (fail): anything not listed is not authorised. The strictest option.
  • ~all (softfail): anything not listed is probably not authorised; accept but treat with suspicion.
  • ?all (neutral): no opinion. Offers almost no protection.
  • +all: authorises the entire internet to send as you. Never use it.

Which to pick? ~all is the safe starting point while you track down every service that sends for you. Once your DMARC reports show nothing legitimate failing, you can move to -all. Bear in mind that once DMARC is enforcing, receivers mostly act on the DMARC result, so ~all with a strong DMARC policy is a perfectly sound long-term setup. Some receivers reject -all failures before DMARC gets a look in, which can catch out forwarded mail.

Examples for common providers

Always check your provider's current documentation, but these are the standard includes for the two big business mail platforms:

Google Workspace

v=spf1 include:_spf.google.com ~all

Microsoft 365

v=spf1 include:spf.protection.outlook.com ~all

Microsoft 365 plus a web server that sends contact form email

v=spf1 include:spf.protection.outlook.com ip4:198.51.100.10 ~all

For marketing and transactional platforms, look in their domain authentication settings. Many of them handle SPF on their own return-path domain via a CNAME you publish, rather than asking you to add an include to your root record. If the platform does that, adding their include to your root record as well achieves nothing and wastes a lookup.

For a step-by-step setup on each platform, see Google Workspace email authentication and Microsoft 365 email authentication.

Domains, DNS & emaildijitul DNSRegister and transfer .uk and .com domains, with Cloudflare DNS management and business email. SPF, DKIM and DMARC set up properly.Fix your DNS with dijitul

One record per domain

This is the single most common SPF mistake. A domain can have only one TXT record starting with v=spf1. When you sign up for a new service, its setup wizard will often tell you to "add this SPF record", and people add a second one alongside the first. The result is a PermError, and SPF fails for every message from the domain, including your normal mailbox.

Wrong:

example.co.uk.  TXT  "v=spf1 include:_spf.google.com ~all"
example.co.uk.  TXT  "v=spf1 include:mailgun.org ~all"

Right:

example.co.uk.  TXT  "v=spf1 include:_spf.google.com include:mailgun.org ~all"

Other TXT records on the domain (site verification codes and so on) are fine. Only SPF has the one-record rule.

Other limits and gotchas

  • The 10-lookup limit. Evaluating your record may trigger no more than 10 DNS lookups, counting every include, a, mx, exists and redirect, including those nested inside includes. Exceed it and SPF returns PermError. This catches out businesses using several services; see how to fix too many DNS lookups.
  • Void lookups. No more than two lookups may return an empty answer or a non-existent domain. An include pointing at a service you cancelled years ago can trip this.
  • 255-character strings. A single TXT string can hold 255 characters. Longer records are split into several quoted strings within the same record, which receivers join together. Most DNS panels do this for you.
  • Subdomains need their own record. SPF does not inherit. If you send from news.example.co.uk, that name needs its own SPF record.
  • Domains that never send email should publish v=spf1 -all so nobody can pass SPF using them.
  • Forwarding breaks SPF. When a message is forwarded, it arrives from the forwarder's server, which is not in your record. This is expected and is why DKIM matters: a DKIM signature survives simple forwarding.
Check your setup now: run a free test at mail-tester.co.uk and see your score in seconds.

How to set up SPF, step by step

  1. List every system that sends as your domain. Your mailbox provider, website contact forms, CRM, invoicing software, helpdesk, newsletter platform, printers and scanners that email PDFs. Ask colleagues; there is usually one nobody remembers.
  2. Find out how each one authenticates. Some need an include on your root domain, some use a custom return-path subdomain, some send from a fixed IP address.
  3. Check for an existing record. If one exists, edit it. Do not add a second.
  4. Build the record with v=spf1, your mechanisms, and ~all at the end.
  5. Publish it as a TXT record on the root of your domain.
  6. Test it by sending a real message from each service.
  7. Add DKIM and DMARC. SPF on its own is not enough to meet the Gmail and Yahoo bulk-sender rules introduced in February 2024 or Microsoft's Outlook.com rules from May 2025. See Gmail and Yahoo sender requirements.

Testing your SPF record

A DNS lookup only tells you the record exists. The useful test is sending a real message and seeing what the receiver concludes. When you send a test to Mail Tester UK, the report shows the SPF result (pass, fail, softfail, neutral, none or permerror), which IP was checked, the envelope domain that was evaluated and whether it aligns with your From domain for DMARC.

Test from every system that sends for you, not just your main mailbox. A record that passes for Google Workspace can still be missing the CRM that sends your quotes.

Keep a short note of which service each part of your SPF record is for. In a couple of years, when someone asks whether include:something.net can be removed, you will be glad of it.

Frequently asked questions

Can I have two SPF records on one domain?

No. A domain must publish exactly one TXT record starting with v=spf1. Two records cause a PermError and SPF fails for every message, so merge all your senders into a single record.

Should I use ~all or -all?

Use ~all (softfail) while you are still confirming every sending service is listed, then consider -all once you are confident. With DMARC in place, most receivers base their decision on DMARC rather than the SPF qualifier alone.

Does SPF check the From address people see?

No. SPF checks the envelope sender (the Return-Path or MAIL FROM address), not the visible From header. DMARC is what ties the result back to the visible From domain through alignment.

How long does an SPF change take to work?

As long as the old record's TTL, which is often an hour or less but can be up to a day. Test again after the TTL has passed.

From the team behind Mail Tester UK

More from dijitul