How to Set Up an SPF Record: Step-by-Step Guide
A step-by-step guide to setting up an SPF record: find your sending sources, build the record, publish it at your DNS provider, and verify it with an SPF checker.
TL;DR To set up an SPF record: (1) identify every service that sends email for your domain, (2) build a TXT record listing them, (3) publish it at your DNS provider, and (4) verify it looks correct. An SPF record is a single TXT record at your domain root — you can have exactly one.
An SPF record tells receiving mail servers which IP addresses and services are authorized to send email on behalf of your domain. Without it, anyone can send email that claims to be from your domain. With it, receiving servers can check whether the sending server is on your approved list and reject or flag messages that aren't.
For a conceptual overview of how SPF works, see What Is an SPF Record?.
Before writing a single character of SPF, make a complete list of everything that sends email using your domain in the From: or envelope sender address.
Common sending sources:
Why this step matters: every service you miss will have its emails fail SPF. If you add a service later, you need to update your SPF record. Build the complete list now.
Check your domain's existing TXT records — if SPF is already partially configured, you can see what's already included:
dig example.com TXTAlso ask your team — marketing, sales, and support tools are often added without IT involvement.
SPF records are TXT records that start with v=spf1 and end with an all mechanism. In between, you list your authorized senders.
Most email service providers publish their own SPF record that you reference with include:. Check your provider's documentation for the exact include value. Common ones:
| Service | SPF include |
|---|---|
| Google Workspace | include:_spf.google.com |
| Microsoft 365 | include:spf.protection.outlook.com |
| SendGrid | include:sendgrid.net |
| Mailgun | include:mailgun.org |
| Postmark | include:spf.mtasv.net |
| Amazon SES (US East) | include:amazonses.com |
| Mailchimp | include:servers.mcsv.net |
| HubSpot | include:hubspotemail.net |
| Zendesk | include:mail.zendesk.com |
If you run your own mail server, add its IP directly:
ip4:203.0.113.10 # Single IPv4 address
ip4:203.0.113.0/24 # IPv4 CIDR range
ip6:2001:db8::1 # IPv6 addressEnd every SPF record with one of:
~all — softfail: mail from unlisted sources is accepted but marked suspicious. Safe starting point.-all — hardfail: mail from unlisted sources is rejected. Use this once you're confident your record is complete.?all — neutral: no policy. Provides no protection — don't use it.Combine everything into a single space-separated string:
v=spf1 include:_spf.google.com include:sendgrid.net ip4:203.0.113.10 ~allImportant: you can only have one SPF record per domain. If you have multiple services, combine them into a single record — multiple v=spf1 records cause a PermError.
SPF has a hard limit of 10 DNS lookups during evaluation. Each include:, a, and mx mechanism counts as one lookup — and includes can nest. If you exceed 10 lookups, SPF returns PermError and the check fails.
Count your includes before publishing. If you're at or near 10, consider:
include: with direct ip4: entries where possible (some providers list their IPs)DNS Buddy's SPF Checker expands your full include chain and counts lookups, so you can see the depth before and after making changes.
Log into your DNS provider (wherever you manage your domain's DNS — your registrar, Cloudflare, Route 53, etc.) and create a TXT record:
| Field | Value |
|---|---|
| Name / Host | @ (or leave blank, or your domain name — depends on the provider) |
| Type | TXT |
| Value / Content | Your SPF record string, e.g. v=spf1 include:_spf.google.com ~all |
| TTL | 3600 (or your provider's default) |
Cloudflare: Enter @ for the Name field. Paste the record value without quotes.
AWS Route 53: The record value must be wrapped in double quotes: "v=spf1 include:_spf.google.com ~all".
GoDaddy / Namecheap: Use @ or leave Name empty. Some interfaces show the domain name — don't repeat it.
Google Domains / Squarespace: TXT records go under "Custom records." Use @ for the host.
Existing SPF record: If a TXT record starting with v=spf1 already exists, edit it rather than adding a second one. Two SPF records = PermError.
DNS changes don't take effect immediately. New TXT records propagate based on the TTL. If your domain's default TTL is 3,600 seconds, allow up to an hour before checking.
During propagation, some resolvers may still see the old record. If you're verifying shortly after publishing, query your authoritative nameserver directly to confirm the record was saved:
# Replace ns1.example.com with your actual nameserver
dig @ns1.example.com example.com TXTOnce propagated, verify the record looks correct and is valid.
Use DNS Buddy's SPF Checker to:
dig example.com TXT | grep spfThe output should show your record. If nothing appears, propagation may still be in progress, or the record wasn't saved correctly.
After verifying the record looks correct, send a test email to an address you control at Gmail or another provider. In Gmail, open the message, click the three-dot menu, select "Show original," and look for the Authentication-Results header:
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of user@example.com designates
203.0.113.10 as permitted sender) ...spf=pass confirms the check succeeded. spf=fail or spf=softfail means something is still wrong.
The most common setup error: adding a second TXT record starting with v=spf1 instead of editing the existing one. Always edit — never add a second.
# Wrong — two SPF records
example.com TXT "v=spf1 include:_spf.google.com ~all"
example.com TXT "v=spf1 include:sendgrid.net ~all"
# Right — one combined record
example.com TXT "v=spf1 include:_spf.google.com include:sendgrid.net ~all"If a service sends email on your behalf but isn't in your SPF record, those emails will fail SPF. Common ones people forget: CRMs, support ticket systems, bulk email tools, and automated notification services.
Adding too many include: statements, especially ones that chain to other includes, can push you over the 10-lookup limit. Check the lookup count before and after changes with DNS Buddy's SPF Checker.
+all or ?all+all means "authorize everyone" — it provides no protection. ?all means "no policy" — same problem. Always use ~all or -all.
If you have subdomains that never send email (noreply.example.com, mail.example.com), publish v=spf1 -all for them — an SPF record with nothing authorized. This prevents spammers from exploiting your unused subdomains.
SPF alone is not enough for reliable email deliverability and spoofing protection.
Publishing all three (SPF + DKIM + DMARC) is the current standard for business email. Major inbox providers (Gmail, Yahoo, Microsoft) are increasingly requiring all three for reliable delivery.