Contact us

Product

SPF records: syntax, examples and common mistakes

An SPF record is one line of text in your DNS, and it is easy to get wrong. This guide shows the syntax, working examples for Microsoft 365 and Google Workspace, and how to stay inside the limits that make SPF fail.

  • We reply by email
  • Forever Systems, part of Forever Group

In short

An SPF record is a DNS TXT record, starting v=spf1, that lists the servers allowed to send email using your domain in the envelope (MAIL FROM) address. Receiving servers check it on every message. Each domain may have only one SPF record, it must need no more than ten DNS lookups, and it ends with -all or ~all.

Get a quote for SPF records

Tell us roughly how many users or sites you have and we will reply by email with options and a quote.

Contact us

What an SPF record does, and what it does not

SPF (Sender Policy Framework, RFC 7208) lets you publish which servers may send mail for your domain. When a message arrives, the receiving server looks up the SPF record for the domain in the envelope sender (the MAIL FROM or return-path address) and checks whether the sending IP address is on the list.

SPF has three limits worth knowing before you rely on it:

  • It checks the envelope domain, not the From address people see. A criminal can pass SPF for their own domain while showing yours in the From line. DMARC closes that gap by requiring the SPF domain to align with the visible From domain.
  • It breaks when mail is forwarded, because the forwarding server is not in your record. DKIM survives forwarding better, which is why you need both.
  • It covers one domain or subdomain at a time. The record for example.co.uk does not cover news.example.co.uk; each subdomain that sends mail needs its own.

SPF on its own does not stop anyone spoofing your domain. It is one input to DMARC, explained on our email authentication hub and in our sister site's DMARC guide.

SPF record syntax

Every SPF record starts with v=spf1, lists the permitted sources (mechanisms) from left to right, and ends with an all mechanism that says what to do with everything else:

TermWhat it meansCounts towards the 10 lookups?
v=spf1Identifies the TXT record as SPF; must come firstNo
ip4: and ip6:A single IP address or a CIDR range allowed to sendNo
include:Also allow whatever another domain's SPF record allows; used for Microsoft 365, Google Workspace and most sending servicesYes, plus any lookups inside the included record
a and mxAllow the IP addresses of the domain's A or MX recordsYes
existsAdvanced macro-based check, rarely neededYes
redirect=Use another domain's SPF record instead of this oneYes
ptrReverse DNS check; RFC 7208 says it should not be publishedYes
-allHard fail: everything else is not authorisedNo
~allSoft fail: everything else is probably not authorisedNo
?allNeutral: no statement; for testing onlyNo

Do not use +all, which authorises every server on the internet to send as you. RFC 7208 also asks receivers to limit void lookups (DNS queries that return no answer, often from an include for a service that no longer exists) to two, so dead includes can break SPF as well as waste lookups.

Not sure which option fits? Ask us

Tell us what you need and we will recommend the right option for your organisation, with a quote.

Contact us

SPF record examples

These examples use example.co.uk and documentation IP addresses. Replace them with your own domain, your own IP addresses and the include values your providers publish:

ScenarioSPF record
Microsoft 365 onlyv=spf1 include:spf.protection.outlook.com -all
Google Workspace onlyv=spf1 include:_spf.google.com ~all
Google Workspace and Microsoft 365 (during a migration)v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all
Microsoft 365 plus an on-premises serverv=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all
Marketing platform on a subdomain (news.example.co.uk)v=spf1 include:_spf.mailprovider.example -all
Parked domain that sends no mailv=spf1 -all

Publish the record as a TXT record at the domain itself (often entered as @ at your DNS host). Microsoft recommends a TTL of at least 3,600 seconds to avoid DNS lookup timeouts. There is nothing to configure inside Microsoft 365 or the Google Admin console: both say SPF is set at your domain host.

Should SPF end in -all or ~all?

The two biggest mail platforms give different advice:

  • Microsoft recommends -all for Microsoft 365 domains, because it also recommends DKIM and DMARC. It notes that DMARC treats both -all and ~all as SPF failures, but that a DMARC policy is effectively ignored for ~all failures when a message has no DKIM signature.
  • Google recommends ~all for Google Workspace domains, which tells receivers to treat unlisted senders as suspicious rather than reject them outright.

In practice the choice matters less once DKIM and DMARC are in place, because DMARC then decides what happens to failing mail. A sensible rule is to follow your main platform's advice for active domains, and to use v=spf1 -all for every parked domain. Use ?all only while testing.

Is SPF records the right fit for you?

We will check it against your systems and requirements and recommend the right option.

Contact us

The 10 DNS lookup limit

RFC 7208 limits SPF evaluation to ten DNS-querying terms. The include, a, mx, ptr and exists mechanisms and the redirect modifier each count; ip4, ip6 and all do not. Lookups inside an included record count too, so ten include statements can easily mean more than ten lookups. If evaluation goes over the limit, SPF returns a permerror and the message fails SPF.

Ways to get back under the limit:

  1. Remove senders you no longer use. Old newsletter tools and retired CRMs are the usual culprits.
  2. Move bulk and marketing services to subdomains. Each subdomain has its own record and its own budget of ten lookups, and Microsoft recommends this anyway to protect your main domain's reputation.
  3. Replace an include with IP ranges where a vendor publishes a stable, documented set of addresses, and review it regularly. Microsoft says not to do this for Microsoft 365, whose sending IP addresses change frequently.
  4. Use hosted SPF. Valimail's Instant SPF answers each query with a record tailored to the sending server, and IRONSCALES DMARC flattens SPF automatically at frequent intervals, so neither is constrained by the limit in the same way.

Google's help page describes the limit as up to ten include tags. Microsoft's is more precise about nested lookups, so count every level when you check a record.

Common SPF mistakes

Most SPF failures come from a handful of errors:

MistakeWhat happensFix
Two SPF records on one domainPermerror: receivers cannot tell which to useMerge them into a single record
Trailing full stop after an include domainThe include does not resolve as intendedRemove the trailing full stop
include= instead of include:Syntax errorUse a colon
A space after the colonSyntax errorWrite include:domain with no space
An include that does not resolve or has no SPF recordPermerror, and a void lookupCheck each include domain; delete dead ones
More than ten lookupsPermerrorUse the steps above
A sender missing from the recordThat service's mail fails SPFAdd it, or move it to a subdomain
Relying on the parent record for a subdomainThe subdomain has no SPF at allPublish a record for each sending subdomain
Using +allAnyone can pass SPF as your domainEnd with -all or ~all

The trailing full stop, include= and stray space errors are the examples Microsoft gives in its own SPF guidance, and Microsoft also notes that two records, or an include that does not resolve, cause a permerror.

Adding third-party senders and gateways

Every service that sends with your domain in the envelope address needs to be covered: add the include or IP ranges given in that provider's documentation. Better still, turn on the provider's DKIM signing with your domain, because DKIM alignment survives forwarding and does not use up SPF lookups.

If your outbound mail is relayed through a secure email gateway, such as Proofpoint Essentials, Symantec Email Security.cloud, Trend Micro's Cloud Email Gateway Protection or Sophos Email in gateway mode, the gateway becomes the server that delivers your mail to the world. Add the SPF value that gateway's documentation specifies, and keep your Microsoft 365 or Google Workspace include only if some mail can still leave directly. API-based products that inspect mail inside the mailbox do not normally send on your behalf, so they usually need no SPF change; check the vendor's documentation for features such as encrypted delivery portals that do send mail.

How to check an SPF record

There are three quick ways to check:

  • Look up the record. Any DNS lookup tool or SPF checker will show the TXT record for your domain, and many count the DNS lookups for you.
  • Read a message header. Send a message to Gmail, open it and choose More, then Show original; the authentication results show whether SPF passed and for which domain.
  • Read your DMARC reports. Aggregate reports list every source sending as your domain and whether each one passed SPF, which is how you find senders the record is missing.

SPF is the first item on our Google bulk sender guidelines checklist, because Gmail now requires it, or DKIM, from every sender.

How we help

Forever Systems can review SPF across every domain you own, count the real lookups, remove dead includes, move bulk senders to subdomains and lock down parked domains, then add DKIM and DMARC so SPF is doing a useful job. If your record keeps outgrowing the limit, we supply hosted options such as Valimail and IRONSCALES DMARC; pricing is confirmed at quote. Contact us for a review of your SPF records.

How Forever Systems helps with email security

We are an independent UK IT and cyber security provider. We supply several email security platforms, so we can suggest what suits your mail system, your risks and your budget rather than pushing one product.

  • Start with what you have: we can review the protection already built into Microsoft 365 or Google Workspace before suggesting anything extra
  • Compare like for like: API-based protection, secure email gateways, encryption and DLP from the vendors we supply, explained in plain English
  • Get authentication right: we help you plan SPF, DKIM, DMARC and MTA-STS so genuine mail is delivered and spoofed mail is not
  • Deployment help: connecting a platform to Microsoft 365 or Google Workspace, mail routing changes and policy set-up, scoped at quote
  • People and backup too: security awareness training, Check Point Harmony Email & Collaboration and Sophos from our specialist sites

Tell us about your mail system and we will suggest options, with pricing confirmed at quote.

Frequently asked questions

What does an SPF record look like?

An SPF record is a single TXT record that starts with v=spf1, lists permitted senders and ends with an all mechanism. For a domain using only Microsoft 365 it is v=spf1 include:spf.protection.outlook.com -all, and for Google Workspace only it is v=spf1 include:_spf.google.com ~all.

Can a domain have two SPF records?

No. Only one SPF record is allowed per domain or subdomain. Two records cause a permanent error, so receivers treat SPF as failed. Merge all your senders into one record.

What is the SPF record for Google Workspace?

Google's recommended record for a domain that sends only through Google Workspace is v=spf1 include:_spf.google.com ~all. Add an include for each other service that sends as your domain.

Should my SPF record end in -all or ~all?

Microsoft recommends -all for Microsoft 365 domains and Google recommends ~all for Google Workspace. Once DKIM and DMARC are in place, DMARC decides what happens to failing mail, so either works. Parked domains that send nothing should use v=spf1 -all.

What happens if SPF has more than 10 DNS lookups?

SPF evaluation stops with a permanent error (permerror) and the message fails SPF. Include, a, mx, ptr, exists and redirect each count, including lookups nested inside included records. Remove unused senders, move bulk senders to subdomains or use a hosted SPF service.

Does SPF stop email spoofing?

Not on its own. SPF checks the hidden envelope domain, not the From address people see. It only stops spoofing of your visible domain when combined with DMARC at a policy of quarantine or reject.

Still have a question about SPF records?

Ask us and a member of our team will reply by email.

Contact us

Next step

Want help choosing an email security platform?

Tell Forever Systems what you need and we will come back to you by email with options and next steps.

  1. 1
    Tell us what you needA few lines is enough: your organisation, users or sites, and timescales.
  2. 2
    We read it and reply by emailWith options and clear next steps.
  3. 3
    You decideChoose the option that suits you and we take it from there.

Email Security UK is a website of Forever Systems, part of Forever Group. Vendor-independent. We supply and support several email security platforms, so we recommend what fits.

Send a quick enquiry

We reply by email.

About: SPF records

We only use these details to reply to your enquiry.

Talk to us about SPF records

We reply by email.

We only use these details to reply to your enquiry.
Talk to us aboutSPF records
Contact us