How to create an SPF record: a step-by-step guide with examples for Google, Microsoft 365 and Zoho
TL;DR: SPF (Sender Policy Framework) is a single DNS TXT record that lists the servers allowed to send email for your domain. Build it in four steps: list every service that sends mail as your domain, add an include: or IP for each, end with ~all or -all, and publish it as one TXT record at the root of your domain. A domain must have only one SPF record, and the record may trigger no more than 10 DNS lookups. Test it with a real message and read the Received-SPF or Authentication-Results header.
What SPF does
When someone receives an email that claims to come from [email protected], their server looks up the SPF record for example.com. The record lists the servers allowed to send for that domain. If the sending server is on the list, SPF passes. If not, the message may be marked as spam or rejected, depending on your policy and the receiver.
SPF checks the sending server, not the visible From address alone, and it works best together with DKIM and DMARC. If you want the whole picture, see why business emails go to spam.
SPF syntax in plain language
An SPF record is a line of text beginning with v=spf1, followed by rules, ending with a policy for everything else.
v=spf1 include:_spf.google.com ip4:203.0.113.10 ~all
| Part | Meaning |
|---|---|
v=spf1 |
Identifies the record as SPF. Always first |
include:domain |
Also allow the senders listed in that domain's SPF record |
ip4:address or ip6:address |
Allow a specific IP address or range |
a |
Allow the IP in your domain's A record |
mx |
Allow your domain's mail servers |
~all |
Soft fail: mail from other senders is suspicious but usually accepted |
-all |
Hard fail: mail from other senders should be rejected |
?all |
Neutral: no opinion. Rarely useful |
+all |
Allows everyone. Never use it |
Most domains start with ~all while they confirm every sender is listed, then move to -all when they are sure.
Step 1: list every sender
This is where most mistakes are made. Make a list of everything that sends mail as your domain:
- your main mailbox provider (Google Workspace, Microsoft 365, Zoho, hosting email),
- your website, if it sends form or order emails, ideally through an SMTP service. See WordPress not sending emails,
- newsletter and marketing tools,
- transactional services for receipts and OTPs,
- billing, helpdesk and CRM systems,
- your own server, if it sends mail directly.
If you are not sure, send test mail from each system to a Gmail address and read the headers, or check your DMARC reports if you have them.
Step 2: build the record
Start with v=spf1. Add one entry per sender, using the include: value the service documents. End with your policy.
A domain that uses Google Workspace and a newsletter tool:
v=spf1 include:_spf.google.com include:servers.mcsv.net ~all
A domain that uses Microsoft 365 and sends from its own server at 203.0.113.10:
v=spf1 include:spf.protection.outlook.com ip4:203.0.113.10 ~all
Keep it as short as possible. Every include:, a, mx and a few other mechanisms count towards a limit of 10 DNS lookups. Go over it, and SPF fails with a permanent error, which is explained in our guide to SPF "too many DNS lookups".
Common includes by provider
These are widely used values. Always confirm against your provider's current documentation, because they can change and some vary by region.
| Service | Typical SPF entry |
|---|---|
| Google Workspace | include:_spf.google.com |
| Microsoft 365 | include:spf.protection.outlook.com |
| Zoho Mail (India data centre) | include:zoho.in |
| Zoho Mail (global) | include:zoho.com |
| Amazon SES | include:amazonses.com |
| SendGrid | include:sendgrid.net |
| Mailchimp | include:servers.mcsv.net |
Zoho is a good example of why you should check: accounts on the Indian data centre use a different include from accounts on the global one.
If your email comes from your hosting provider's mail server, the provider will tell you the right entry, which is often an include for their mail domain or the server's IP address.
Step 3: publish it
Add the record in your DNS panel, wherever your nameservers are managed.
- Open the DNS zone for your domain.
- Check for an existing record whose value begins with
v=spf1. If there is one, edit it instead of adding a second. - Create or edit a TXT record.
- Set the host or name to
@(the root of the domain), or leave it blank, depending on the panel. - Paste the SPF value, including
v=spf1at the start. - Save, and wait for the change to spread. See DNS propagation.
Do not put the record on www or another subdomain unless that subdomain sends mail itself. Subdomains that send mail need their own SPF record.
Step 4: test it
Look up the record first:
dig example.com TXT +short
You should see exactly one value beginning with v=spf1. For other lookup tools and what the answers mean, read how to check DNS records.
Then test with real mail:
- Send an email from each system to a Gmail address.
- Open the message and choose Show original.
- Look for
SPF: PASSalong with your domain.
Test every sender, not only your mailbox. A newsletter tool or form plugin that was missed will show SPF: FAIL or SOFTFAIL.
Mistakes that break SPF
- Two SPF records. Having two TXT records that begin with
v=spf1makes SPF fail. Merge them into one. - Too many lookups. More than 10 lookups causes a permanent error. Remove unused includes, and avoid stacking many services.
- Forgetting a sender. The most common cause of legitimate mail landing in spam.
- Using
+all. This lets anyone send as you. - A typo in an include. A misspelt domain counts as an error.
- Wrong place. Publishing the record on the wrong host name, or adding quotation marks in a way your DNS panel does not expect.
- Leaving old services. Remove includes for tools you no longer use.
- Expecting SPF to survive forwarding. Forwarded mail often fails SPF because it arrives from the forwarder's server. This is one reason DKIM and DMARC matter. See DMARC without breaking email forwarding.
- Treating a generator as final. Online SPF generators help you assemble the text, but they cannot know your senders. Check the output against your list.
SPF alone is not enough
SPF is one of three checks. Add DKIM, which signs each message (see how to find your DKIM selector), and a DMARC policy that tells receivers what to do when checks fail. For a complete set-up of email on your own domain, follow how to set up business email.
FAQs
What is an SPF record?
A DNS TXT record that lists the servers allowed to send email for your domain, so receivers can detect forged mail.
Where do I add an SPF record?
In your domain's DNS zone, as a TXT record at the root (@). Use the panel of whoever hosts your nameservers.
Can I have two SPF records?
No. Only one record starting with v=spf1 is allowed per domain. Combine them into a single record.
Should I use ~all or -all?
Start with ~all while you confirm all senders are listed, and move to -all once you are sure. Many organisations stay on ~all with DMARC enforcing the policy.
What is the SPF 10 lookup limit?
SPF allows at most 10 DNS lookups in total while evaluating a record. Includes, a, mx and similar mechanisms count. Exceeding it gives a permanent error.
Why does my email still go to spam with a correct SPF?
SPF is only one factor. Missing DKIM or DMARC, poor sender reputation, content and blocklists also matter.
Do I need an SPF record for a domain that does not send email?
Yes, it is good practice to publish v=spf1 -all on a domain that sends no mail, to stop others from forging it.
How long does an SPF change take to work?
It depends on the record's TTL and resolver caches, usually minutes to a few hours.
Conclusion
A working SPF record is a short list built carefully: every real sender, one record per domain, fewer than 10 lookups and a sensible closing policy. Build it from your sender list, publish it at the root, test with real messages and keep it tidy as your tools change.
HostCloud's email and DNS services help you set up SPF, DKIM and DMARC correctly. See https://hostcloud.in.
Sources: