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

  1. Go to dash.cloudflare.com
  2. Select your domain from the list

2Go to DNS Settings

  1. Click "DNS" in the left sidebar
  2. 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

  1. Click "Save"
  2. Changes typically propagate within 5 minutes

SPF Record Examples

Google Workspace Only

v=spf1 include:_spf.google.com ~all

Microsoft 365 Only

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

Google Workspace + Mailchimp

v=spf1 include:_spf.google.com include:servers.mcsv.net ~all

Multiple Services (Common Setup)

v=spf1 include:_spf.google.com include:sendgrid.net include:spf.hubspot.com ~all

Common 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

MechanismPurposeExample
include:Add another domain's SPFinclude:_spf.google.com
ip4:Allow specific IPv4ip4:192.168.1.1
ip6:Allow specific IPv6ip6:2001:db8::1
a:Allow domain's A recorda:mail.example.com
mxAllow domain's MX serversmx
~allSoft fail (spam folder)~all
-allHard 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 Domain

Free scan. Fix for €49 one-time.