How to Set Up SPF in Cloudflare
Stop your emails from going to spam with a properly configured SPF record.
Check if your SPF is configured correctly
What is SPF and Why Do You Need It?
SPF (Sender Policy Framework) is a DNS record that tells email servers which IP addresses are allowed to send email on behalf of your domain.
- ✓Prevents spoofing — tells servers which IPs can send email for your domain
- ✓Improves deliverability — without SPF, your emails may go to spam or be rejected
- ✓Required for authentication — part of the SPF + DKIM + DMARC trio
- ✓Easy to set up — just one TXT record in Cloudflare
Before You Start
Checklist before adding SPF:
- ☐Your domain is using Cloudflare DNS (orange cloud or DNS only)
- ☐You know which services send email for your domain
- ☐You have access to your Cloudflare account
Step-by-Step: Adding SPF in Cloudflare
1Log in to Cloudflare
- Go to dash.cloudflare.com
- Select your domain from the list
2Go to DNS Settings
- Click "DNS" in the left sidebar
- Click "Add record"
3Create the TXT Record
- Type:
TXT - Name:
@(or leave blank for root domain) - Content: Your SPF record (see examples below)
- TTL:
Auto
4Save
- Click "Save"
- Changes typically propagate within 5 minutes
SPF Record Examples
Google Workspace Only
v=spf1 include:_spf.google.com ~allMicrosoft 365 Only
v=spf1 include:spf.protection.outlook.com ~allGoogle Workspace + Mailchimp
v=spf1 include:_spf.google.com include:servers.mcsv.net ~allMultiple Services (Common Setup)
v=spf1 include:_spf.google.com include:sendgrid.net include:spf.hubspot.com ~allCommon Cloudflare SPF Mistakes
1. Multiple SPF records
You can only have ONE SPF record per domain. If you need multiple services, combine them in a single record.
2. Missing v=spf1
Every SPF record must start with v=spf1. Without it, the record is invalid.
3. Using +all instead of ~all
Never use +all — it allows anyone to send email as your domain. Use ~all (soft fail) or -all (hard fail).
4. Forgetting a service
Make sure all your email senders are included. Forgot Mailchimp? Your campaigns will fail SPF checks.
5. Too many lookups
SPF has a 10 DNS lookup limit. If you exceed it, your SPF fails completely.Learn how to fix this →
How to Verify Your SPF Record
After adding the record, verify it's working:
- →Use our free scanner to check your SPF configuration
- →Or use terminal:
dig TXT yourdomain.com - →Look for a record starting with
v=spf1
SPF Syntax Quick Reference
| Mechanism | Purpose | Example |
|---|---|---|
include: | Add another domain's SPF | include:_spf.google.com |
ip4: | Allow specific IPv4 | ip4:192.168.1.1 |
ip6: | Allow specific IPv6 | ip6:2001:db8::1 |
a: | Allow domain's A record | a:mail.example.com |
mx | Allow domain's MX servers | mx |
~all | Soft fail (spam folder) | ~all |
-all | Hard fail (reject) | -all |
Related Guides
Is Your SPF Record Working?
Scan your domain for free. We'll check your SPF configuration, count your DNS lookups, and show you exactly what needs to be fixed.
Check Your DomainFree scan. Fix for €49 one-time.