Skip to main content
WebTools

How to write an SPF record, with examples for common providers

What each part of an SPF record means, the includes for Google Workspace, Microsoft 365 and other providers, where to publish it and how to stay within 10 lookups.

Published

Illustration of a clipboard list of DNS entries connected to server and cloud icons, beside a ten-segment dial.
On this page

The short answer: An SPF record is one TXT record at your domain that lists every server allowed to send email as it. It starts with v=spf1, adds an include: for each email provider and ip4: or ip6: for your own servers, and ends with ~all or -all. For Google Workspace alone, that's v=spf1 include:_spf.google.com ~all. Keep to one record, and stay within the limit of 10 DNS lookups.

This guide explains each part of the record, gives examples for common providers, and covers the mistakes that make SPF fail.

What SPF does

SPF (Sender Policy Framework), defined in RFC 7208, lets a receiving mail server check whether the server delivering a message is allowed to send for the domain it claims. The receiver looks up your SPF record, works through it from left to right, and stops at the first part that matches the sending server's address.

SPF checks the hidden envelope sender (the bounce address), not the From address people see. That's why SPF on its own doesn't stop spoofing, and why DMARC matters: DMARC passes on SPF only when the envelope domain matches your From domain. SPF also always fails when mail is forwarded, because the forwarding server isn't on your list. DKIM covers that case, which is why you need both.

Diagram of the SPF record v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all split into four parts: the version, your own server addresses, a provider include that counts towards the 10 lookups, and the ending for every other server.
The four parts of a typical SPF record.

The parts of an SPF record

PartExampleWhat it meansLookups
Versionv=spf1Marks the record as SPF. Must come first.0
Includeinclude:_spf.google.comUses the provider's own list of servers.1, plus any inside it
IPv4 addressip4:203.0.113.10 or ip4:203.0.113.0/28One server or a range.0
IPv6 addressip6:2001:db8::/64The same for IPv6.0
MXmxThe servers that receive your mail may also send it.1
AaThe domain's own address may send.1
Ending~all or -allWhat to do with every other server. Must come last.0

Two other mechanisms exist but rarely belong in a new record. ptr is slow and unreliable, and RFC 7208 section 5.5 says it should not be published. exists is for advanced, macro-based setups that a provider will tell you about if you need one.

~all or -all?

Both say that servers not on the list aren't allowed. ~all is a soft fail: receivers should treat the mail with more suspicion but, under RFC 7208 section 8.5, not reject it on that result alone. -all is a fail, a firmer statement that receivers may use to reject. If you have DMARC, it decides what happens to failing mail, so ~all is the usual choice and avoids rejections from forwarded mail before DMARC is even checked. Use -all when you are sure the list is complete, or for a domain that sends no email at all.

Try it now

SPF Record Generator

Create an SPF record: tick your email providers, add your servers and get one valid record, with its DNS lookups counted live against the limit of 10.

Open the tool: SPF Record Generator

Examples for common providers

These are the includes the providers publish in their own help pages. Check the provider's current page before you publish, because they occasionally change. Our SPF Record Generator uses the same values and links to each source.

ProviderInclude to add
Google Workspace (Gmail)include:_spf.google.com
Microsoft 365include:spf.protection.outlook.com
Zoho Mailinclude:zohomail.com
Fastmailinclude:spf.messagingengine.com
Proton Mailinclude:_spf.protonmail.ch
Zendeskinclude:mail.zendesk.com
Brevoinclude:spf.brevo.com
Mailguninclude:mailgun.org, on the domain you set up in Mailgun
SendGridinclude:sendgrid.net, only if automated security is off

Sources: Google Workspace, Microsoft 365 and Zoho Mail. Mailgun and SendGrid usually work on a subdomain or through CNAME records they give you, so read their setup page rather than adding the include to your main domain by habit.

Worked examples

Microsoft 365 only:

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

Google Workspace, a help desk and a newsletter service:

v=spf1 include:_spf.google.com include:mail.zendesk.com include:spf.brevo.com ~all

Microsoft 365 plus your own web server, which sends contact form email from 203.0.113.10:

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

A domain that sends no email at all, such as a parked domain:

v=spf1 -all

Put IP addresses before includes. Receivers stop at the first match, and an address match needs no lookups, so it is slightly quicker and uses none of your limit.

Where to publish it

Add the record as a TXT record at the domain itself. Most DNS panels show this as @ or ask you to leave the name blank. Don't put it at _spf or www: receivers only look at the domain used in the envelope sender.

A domain must have only one SPF record. RFC 7208 section 3.2 says a domain must not publish records that would make the check select more than one, and receivers treat two as a permanent error, so SPF fails for every message. This is the most common SPF mistake: a new provider's setup page says "add this TXT record", and someone adds a second v=spf1 record instead of adding the include to the existing one. If you already have a record, edit it.

Subdomains need their own record if they send email. A record on example.com doesn't cover news.example.com.

Long records

A single TXT string can hold up to 255 characters. Longer records are split into several quoted strings, which receivers join together without spaces (RFC 7208 section 3.3). Most DNS panels do this for you. Section 3.4 also recommends keeping all of a name's TXT records under about 450 characters in total, so the answer fits in one small DNS packet. If you are near that, you probably have includes you no longer use.

The 10-lookup limit

Receivers stop after 10 DNS lookups while checking SPF. Every include, a, mx, exists and redirect counts, and so does every one of those inside each include. Go over 10 and SPF returns a permanent error for every message (RFC 7208 section 4.6.4). When we checked in November 2026, the Google Workspace and Microsoft 365 includes each cost one lookup, because they list addresses directly. Other providers' includes contain further includes and cost several, so a handful of services can use much of the limit.

The same section suggests receivers allow only 2 "void" lookups, ones that find nothing. An include pointing at a name that doesn't exist, often left behind by a provider you stopped using, counts as one. Remove includes for services you no longer use.

If you're over the limit, our guide on the SPF 10-lookup limit explains the options: remove unused includes, move a service to a subdomain, or use IP addresses where a provider allows it.

Try it now

SPF Checker

Check a domain's SPF record: syntax, the 10 DNS-lookup limit across every include, void lookups, and what the "all" setting means.

Open the tool: SPF Checker

Common questions

How long until a new SPF record works?

Usually within minutes for new lookups, but receivers may keep the old record cached until its TTL runs out, often an hour. Our guide on DNS changes and TTL explains why.

My provider isn't listed. What do I add?

Search the provider's help pages for "SPF". They will give an include such as include:spf.example.net, or a list of IP ranges. If they say SPF is handled automatically through CNAME records, you may not need to add anything.

Do I need SPF if I have DKIM?

Yes. Google requires bulk senders to use both, and SPF gives DMARC a second way to pass. DKIM matters more for forwarded mail, SPF for mail that loses its signature on the way.

Should I use the SPF record type?

No. A separate SPF record type once existed but was withdrawn. Publish SPF as a TXT record only.

Checklist

  • Exactly one TXT record at the domain starting with v=spf1.
  • An include for every service that sends as your domain, taken from the provider's own help page.
  • Your own sending servers listed with ip4: or ip6:.
  • No ptr, no +all, and no includes for services you've stopped using.
  • 10 DNS lookups or fewer, including those inside each include.
  • Ends with ~all, or -all when you're sure the list is complete.
  • Domains that send no email have v=spf1 -all.
  • Checked with an SPF lookup after publishing.
  • SPF Record Generator

    Create an SPF record: tick your email providers, add your servers and get one valid record, with its DNS lookups counted live against the limit of 10.

  • SPF Checker

    Check a domain's SPF record: syntax, the 10 DNS-lookup limit across every include, void lookups, and what the "all" setting means.