MailScore
Back to blog

How to Set Up SPF, DKIM, and DMARC on Cloudflare (Step-by-Step)

MailScore Team·April 12, 2026·6 min read

Cloudflare is one of the most popular DNS providers, and adding email authentication records is straightforward once you know where everything goes. This guide walks you through adding SPF, DKIM, and DMARC records in the Cloudflare dashboard, step by step.

If you are not sure what SPF, DKIM, and DMARC are or why you need them, read our Email Deliverability Guide first. If you need the actual record values for your email provider (Google Workspace, Microsoft 365, etc.), see our SPF, DKIM, and DMARC setup guide.

Before You Start

You will need:

  • Access to your Cloudflare account with the domain you want to configure
  • The SPF, DKIM, and DMARC values from your email provider (Google Workspace, Microsoft 365, etc.)
  • About 10 minutes

Start by running a free MailScore scan on your domain so you know exactly which records are missing or misconfigured before you begin.

Step 1: Open Your Domain's DNS Settings

  1. Log in to dash.cloudflare.com
  2. Select the domain you want to configure from the dashboard
  3. Click DNS in the left sidebar, then Records

You will see a list of your existing DNS records. All email authentication records are TXT records, which you will add using the Add record button.

Step 2: Add Your SPF Record

SPF tells inbox providers which servers are allowed to send email from your domain.

  1. Click Add record
  2. Set Type to TXT
  3. Set Name to @ (this means your root domain)
  4. Paste your SPF value into the Content field
  5. Leave TTL as Auto
  6. Click Save

Example SPF value for Google Workspace:

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

Important: You can only have one SPF record per domain. If you already have an SPF record, edit it and add additional include: statements rather than creating a second record. Check our setup guide for the correct include values for each email provider.

Cloudflare SPF Tips

  • Cloudflare auto-appends your domain name. If your domain is example.com, entering @ in the Name field creates the record at example.com.
  • The proxy toggle (orange cloud) does not apply to TXT records. TXT records are always DNS-only, so you can ignore the proxy setting.
  • If you see a warning about an existing SPF record, you need to edit the existing one rather than adding a new one.

Step 3: Add Your DKIM Records

DKIM records verify that emails were not tampered with in transit. Your email provider gives you a specific DNS record to add, which includes a public key.

  1. Click Add record
  2. Set Type to TXT (or CNAME if your provider specifies a CNAME record)
  3. In the Name field, enter just the selector and ._domainkey part. For example, if your provider says to create a record at google._domainkey.example.com, enter google._domainkey. Cloudflare appends your domain automatically.
  4. Paste the DKIM value into the Content field
  5. Click Save

Common DKIM Selectors by Provider

Email ProviderName Field in Cloudflare
Google Workspacegoogle._domainkey
Microsoft 365selector1._domainkey and selector2._domainkey (two CNAME records)
SendGrids1._domainkey and s2._domainkey
Amazon SESThree CNAME records (check your SES console for exact values)

Microsoft 365 note: Microsoft uses CNAME records for DKIM, not TXT records. Set the Type to CNAME instead of TXT, and make sure the proxy toggle is off (gray cloud / DNS-only). Cloudflare cannot proxy CNAME records used for email authentication.

Step 4: Add Your DMARC Record

DMARC tells inbox providers what to do when SPF and DKIM checks fail, and where to send reports.

  1. Click Add record
  2. Set Type to TXT
  3. Set Name to _dmarc (Cloudflare appends your domain, creating _dmarc.example.com)
  4. Set Content to: v=DMARC1; p=none; rua=mailto:dmarc@example.com (replace the email with your own)
  5. Click Save

Start with p=none to monitor without affecting email delivery. After 2-4 weeks of reviewing DMARC reports, tighten to p=quarantine and eventually p=reject. Our deliverability guide explains the progression.

Step 5: Verify Your Setup

DNS changes on Cloudflare typically propagate within a few minutes (much faster than the 24-48 hours you might see with other providers). After saving your records:

  1. Wait 2-5 minutes for propagation
  2. Run a free MailScore scan on your domain
  3. Verify that SPF, DKIM, and DMARC all show as passing

If any check fails, double-check the Name and Content fields in Cloudflare. The most common issue is entering the full domain name instead of just the prefix (for example, typing _dmarc.example.com instead of just _dmarc).

Cloudflare-Specific Tips and Common Mistakes

  • Do not proxy email records. CNAME records for DKIM must use DNS-only mode (gray cloud). TXT records are always DNS-only regardless of the toggle.
  • Cloudflare email routing can add its own records. If you use Cloudflare Email Routing, it may automatically create SPF and MX records. Make sure your manually added SPF record includes Cloudflare's sending servers if you use this feature: include:_spf.mx.cloudflare.net.
  • Do not enter the full domain in the Name field. Cloudflare appends your domain automatically. Entering _dmarc.example.com would create a record at _dmarc.example.com.example.com, which is wrong.
  • Check for conflicting records. If you previously used a different email provider, old SPF or DKIM records may still be in your DNS. Delete or update them before adding new ones.
  • DKIM value length: If your DKIM key exceeds 255 characters (common with 2048-bit keys), Cloudflare may automatically split it into multiple quoted strings. This is normal DNS behavior and does not affect functionality. Just paste the full value and Cloudflare handles the formatting.

Keep Your Records Monitored

Email authentication records can break silently when you change email providers, add a new sending service, or let a DKIM key expire. MailScore's monitoring plans (starting at $9/month) scan your domain on a schedule and alert you the moment something breaks.

Check your email deliverability now

Free scan. No signup required. Results in 10 seconds.

Related tools