Email

How to add an SPF record in Cloudflare

To add an SPF record in Cloudflare, open your domain, go to the DNS Records page, select Add record, choose TXT as the Type, enter @ as the Name and your SPF rule as the Content, then select Save. Cloudflare hosts your DNS, not your mailboxes, so the value comes from your mail provider, for example v=spf1 include:_spf.google.com ~all for Google Workspace. If an SPF record already exists, edit it rather than adding a second one.

SPF lists the servers allowed to send email for your domain. A missing or broken record sends your messages to spam and weakens DMARC.

Last verified: November 13, 2026, against Cloudflare's official developer documentation.

Before you start: list everything that sends as you

One SPF record must cover every service that sends email from your address:

  • your mailbox provider: Google Workspace (include:_spf.google.com), Microsoft 365 (include:spf.protection.outlook.com), your web host's email…;
  • your website if it sends email (forms, an online store);
  • newsletter, invoicing and CRM tools.

Each provider documents the include: to use. Cloudflare's own docs recommend email authentication records even for domains that don't send email.

Step 1: check for an existing SPF record

  1. Log in to the Cloudflare dashboard and select your account and domain.
  2. Go to the DNS Records page.
  3. Look for a TXT record on your root domain whose content starts with v=spf1.

You can also go to Email > DMARC Management and select View records under Email record overview. That page lists your existing SPF, DKIM and DMARC records in one place.

Step 2: add or edit the record

  1. On the DNS Records page, select Add record (or Edit on the existing SPF record).
  2. Type: TXT.
  3. Name: @ for the root domain.
  4. Content: your SPF rule, for example Google Workspace plus a newsletter tool:

    v=spf1 include:_spf.google.com include:servers.example-newsletter.com ~all

    Replace the second include: with your real provider's value, or remove it.

  5. TTL: Auto.
  6. Select Save.

If you paste the content without quotes, Cloudflare adds them for you. TXT records are never proxied, so there is no proxy setting to worry about.

If you use Cloudflare Email Routing

Email Routing forwards incoming mail and adds its own SPF record: v=spf1 include:_spf.mx.cloudflare.net ~all. Cloudflare says to merge it with any existing SPF record rather than adding a second one. With Google Workspace, its example is:

v=spf1 include:_spf.mx.cloudflare.net include:_spf.google.com ~all

Step 3: check it works

nslookup -type=TXT yourdomain.com

You should see exactly one line starting with v=spf1. Our free SPF checker also counts the DNS lookups the record triggers.

~all or -all?

  • ~all (softfail): unlisted servers are treated as suspicious but usually not rejected. Use it while you're still finding all your senders.
  • -all (fail): unlisted servers should be rejected.

Move to -all once your DMARC reports show, for several weeks, that every legitimate sender passes SPF. Cloudflare's DMARC Management can collect those reports for you: see how to set up DMARC in Cloudflare.

For a domain that never sends email, publish v=spf1 -all right away.

Known pitfalls

  • Two SPF records: for example one from Email Routing and one from your mail provider. The standard allows one; with two, SPF returns an error.
  • The 10-lookup limit: each include:, a, mx or redirect costs at least one DNS lookup, and includes often chain further. Cloudflare's Email Routing docs warn about it too: past 10, SPF fails. Remove services you no longer use.
  • SPF managed by an external CNAME: Cloudflare's DMARC Management can't change SPF when a CNAME in your zone points to an external domain. Make that change with the external provider.
  • Your DNS isn't on Cloudflare: if your nameservers point elsewhere, records added in Cloudflare have no effect.
  • An include: after all: anything after ~all or -all is ignored.

Frequently asked questions

Does Cloudflare send email for my domain?

Cloudflare's DNS doesn't. Email Routing forwards mail you receive; your outgoing mail goes through your mailbox provider, whose include: belongs in your SPF record.

Is SPF enough to stop my emails going to spam?

No. Turn on DKIM at your mail provider and publish DMARC. Gmail and Outlook.com require all three from senders above 5,000 messages a day.

Verify it's fixed. AttackScout reads your SPF record from the internet, counts DNS lookups, spots duplicates and tells you whether your domain is ready for DMARC. Free, no account needed. Verify it's fixed

Technical details

Exact configuration. A single TXT record at the root of the domain, starting with v=spf1 and ending with an all mechanism:

v=spf1 include:<service-that-sends-your-email> ~all

Why. SPF (RFC 7208) lists the servers allowed to send email for your domain. The receiving server reads this TXT record and counts at most 10 DNS lookups (include, a, mx, exists, redirect): beyond that the result is permerror and SPF protects nothing. Two SPF records also give permerror. ~all flags without rejecting; -all makes receivers reject anything not listed.

To check it yourself. Exactly one line must start with v=spf1:

dig +short TXT your-domain.com

Reference: https://www.rfc-editor.org/rfc/rfc7208

Sources

Accessed November 13, 2026.