Features · SPF, DKIM, DMARC

How do I set up SPF, DKIM and DMARC on Cloudflare?

To set up SPF, DKIM and DMARC on Cloudflare, add 3 DNS records to your zone: SPF lists who may send for your domain, DKIM publishes the key that checks each message's signature, and DMARC tells receivers what to do when both fail. With sendmcp your agent writes all three through the Cloudflare API and checks alignment on a test send.

Updated · Open source, runs on your Cloudflare account

Agent
Add acme.com and set up SPF, DKIM and DMARC.

acme.com is ready to send. I wrote the records to your Cloudflare zone and checked them. Google Workspace also sends as acme.com, so DMARC starts at p=none with reports sent to you, and nothing from Workspace gets refused.

Records for acme.com
SPFTXT record, sending allowed for Cloudflare
pass
DKIMTXT record with the signing key
pass
DMARCTXT record, policy none
pass
Send a test emailRaise DMARC to quarantine later

What do SPF, DKIM and DMARC each do?

RecordDNS typeWhat it proves
SPFTXT on your domainThe sending server is allowed to send for your domain
DKIMTXT under a _domainkey nameThe message was signed with your key and not changed on the way
DMARCTXT on _dmarcSPF or DKIM passes and matches your From domain; sets the policy and where reports go

Receivers such as Gmail check them on every message. A missing or failing record is a common reason mail lands in spam or bounces.

How do I add them by hand on Cloudflare?

  1. Check whether _dmarc already has a record. If it has none, Cloudflare adds v=DMARC1; p=reject; when you onboard the domain, and any other service that sends as your domain without alignment gets refused.
  2. Add the domain to Cloudflare Email Sending. The dashboard shows the DNS records for it.
  3. Add the SPF and DKIM records to the zone under DNS, exactly as shown, and wait for verification.
  4. If other services send as your domain, add a DMARC record that only monitors before you add the domain in step 2, so Cloudflare keeps it instead of adding its own:
# DNS, TXT record _dmarc.acme.com TXT "v=DMARC1; p=none; rua=mailto:dmarc@acme.com"

Start with p=none and read the reports. Once real mail passes, move to quarantine and then reject. If nothing else sends as the domain, such as a new domain or a sending subdomain, keep Cloudflare's p=reject.

How does my agent do it?

Cloudflare shows you the records and leaves the copying to you. Resend has an Auto configure button that signs in to your DNS provider. sendmcp runs inside your Cloudflare account, so your agent writes the records over MCP with no sign-in step, and it also writes DMARC and the tracking CNAME.

StepTool
Add the domain and write SPF, DKIM, DMARC and the tracking CNAMEdomains_add
Check that the records resolvedomains_verify, domains_dns_records
Check DNS, DMARC policy, suppression count and complaint ratedeliverability_check
Send a test and read the resultemails_send_test, events_list

Alignment is checked on the test send, not only in DNS.

Which DMARC policy should I use?

p=none reports and blocks nothing. quarantine sends failing mail to spam, and reject refuses it. deliverability_check shows the policy for each domain, so your agent can tell you which ones are still on none.

sendmcp picks the starting policy from what is already in your zone:

Your domainWhat sendmcp does
Has a DMARC recordLeaves it as it is
No DMARC record, and other services send as it (MX records or other include: entries in SPF)Writes p=none with reports to you before onboarding, so Cloudflare does not add p=reject
No DMARC record, and nothing else sends as itKeeps Cloudflare's p=reject

On a domain that starts at p=none, deliverability_check reads the reports. When every sender passes with alignment, your agent suggests quarantine, then reject. It never changes the policy without asking.

Sources

  1. Cloudflare: Email Service docs checked
  2. Resend docs checked

Questions about this

Do I need all three records?

Set all three. SPF and DKIM prove who sent the mail, and DMARC tells receivers what to do when they fail. sendmcp writes all three when you add a domain.

Why does sendmcp start some domains at p=none?

Because Cloudflare's default p=reject refuses mail from any other service that sends as your domain without alignment, such as Google Workspace or a CRM. When sendmcp finds other senders, it starts at p=none with reports and suggests a stricter policy once they pass. A domain that only sends through Cloudflare keeps p=reject.

Why is my domain stuck on pending?

The records usually need time to propagate. Ask your agent to run domains_verify again, and check with domains_dns_records that each record exists in the zone.

Does passing all three guarantee inbox delivery?

No. They prove you are who you say you are. Inbox placement also depends on your content, your list and Cloudflare's shared IP reputation, so sendmcp makes no deliverability guarantee.

Send from every project for $0.

Open source. One click puts it on your Cloudflare account.