tutorials
Set up MX records to receive mail on your own Cloudflare inbox
November 11, 2026

Mail to your domain bounces or vanishes, and the cause is invisible: an inbound Worker is wired up but the MX records that tell the world where to deliver are missing, wrong, or fighting with a leftover record from a previous host. Here is every DNS record you actually need, what each one does, and the order to add them.
Receiving email is a DNS problem before it is a code problem. A sending server has no idea your inbox lives on Cloudflare. It asks DNS one question: "what is the MX record for this domain?" and delivers to whatever that record names. If the answer is missing, points at a dead host, or still names a Google Workspace you cancelled, your mail never reaches your Worker no matter how perfect the handler is. This guide walks every record from first principles, shows the failures you will actually hit, then notes how npx tinbox init publishes the same set for you. For the higher-level sequence this fits into, the steps to receive inbound email on your own Cloudflare account is the map, and the DNS records every sending domain needs covers the outbound half you will add once you also send.
What MX records do I need to receive email on Cloudflare?
You need Cloudflare Email Routing's three MX records, and they must be the only MX records on the domain. Email Routing publishes them when you enable it:
MX @ route1.mx.cloudflare.net (priority 13)
MX @ route2.mx.cloudflare.net (priority 86)
MX @ route3.mx.cloudflare.net (priority 24)
Alongside them, add the SPF TXT record so mail forwarded on your behalf passes authentication downstream:
TXT @ v=spf1 include:_spf.mx.cloudflare.net ~all
That is the whole inbound DNS picture for a Cloudflare inbox: three MX records and one SPF record. Everything below explains why each line is there, and the ways this goes wrong.
What is an MX record and how does priority work?
An MX (Mail eXchanger) record is a DNS record that names the server responsible for receiving mail for a domain, paired with a priority number. When someone sends to you@yourdomain.com, their outgoing server looks up MX yourdomain.com, gets back one or more hostnames with priorities, and connects to deliver.
Priority is a preference, and lower wins. A sending server sorts the MX records ascending and tries the lowest number first. It only falls back to a higher number if it cannot connect to the preferred host. So Cloudflare's route1 at priority 13 is the primary, and route2 (86) and route3 (24) are fallbacks. The specific numbers are arbitrary; what matters is that multiple hosts exist for redundancy and that they all belong to the same mail system.
You can read your current records with dig:
dig +short MX yourdomain.com
A clean Cloudflare setup answers like this:
13 route1.mx.cloudflare.net.
86 route2.mx.cloudflare.net.
24 route3.mx.cloudflare.net.
If you see anything else in that list, that is the first thing to fix.
Step 1: Remove any existing MX records
Before you add Cloudflare's records, delete the ones already there. A domain can only deliver inbound mail to one mail system at the apex. There is no working "split MX" where some mail goes to Google and some to Cloudflare; sending servers pick one MX target per delivery, so mixing providers gives you nondeterministic, half-broken delivery.
The records that quietly break things are the ones left over from a setup you forgot about. Google Workspace leaves these:
MX @ aspmx.l.google.com (priority 1)
MX @ alt1.aspmx.l.google.com (priority 5)
MX @ alt2.aspmx.l.google.com (priority 5)
MX @ alt3.aspmx.l.google.com (priority 10)
MX @ alt4.aspmx.l.google.com (priority 10)
Because Google's aspmx.l.google.com sits at priority 1, it is preferred over every Cloudflare record (13 and up). Senders will deliver to Google first and never reach Cloudflare. Delete all of them. Microsoft 365 (yourdomain-com.mail.protection.outlook.com) and registrar default MX records have the same effect and must go too. If cutting these over is part of a bigger move off Google, the ways to move your team off Google Workspace email covers the rest of that exit.
Step 2: Enable Email Routing so Cloudflare publishes the MX
In the Cloudflare dashboard, open your domain, go to Email > Email Routing, and run the setup. For a zone Cloudflare already manages, it adds the three MX records and the SPF TXT record automatically. If you manage DNS elsewhere, Cloudflare shows you the exact records to publish at your provider.
Why MX records specifically, and not a Worker route or a CNAME? Because the rest of the email world only understands MX. Cloudflare intercepts mail for your domain at its edge through these MX hosts, runs your routing rules (forward to an address, drop, or hand to a Worker), and your Worker never has to be reachable on port 25. This is the inbound counterpart to the Email Routing catch-all that decides where matched mail goes; the MX records are what get the mail to Cloudflare in the first place.
Step 3: Add the SPF record so forwarded mail does not get rejected
To receive, the MX record is enough. But Email Routing usually forwards mail onward (to your real mailbox or another address), and when it does, the next receiving server checks SPF against the forwarding host. Without the SPF include, that hop can fail authentication and land in spam or bounce.
Publish:
TXT @ v=spf1 include:_spf.mx.cloudflare.net ~all
This authorizes Cloudflare's forwarding infrastructure to send on the domain's behalf. Email Routing also performs SRS (Sender Rewriting Scheme) rewriting on the envelope so forwarded mail survives strict SPF checks, but the include is still required for alignment. If you also plan to send from the domain, you will add a DKIM record and a DMARC record on top of this; see how to confirm SPF, DKIM, and DMARC actually pass once they are in place.
Step 4: Verify a destination and send a test
Add at least one destination address under Destination addresses and click the verification link Cloudflare emails to it. This step is the single most common "my inbox is broken" cause, because an unverified destination is not an error you see at send time. Mail to it is simply dropped.
Then send a test from an external account (your phone, a personal Gmail) to any address at the domain and watch it arrive. If you have a Worker bound, tail it:
npx wrangler tail inbound-mail
GET email handler invoked: to=hello@yourdomain.com from=tester@gmail.com
If nothing shows up, the message did not reach Cloudflare at all, which sends you back to the MX records.
Why is my mail still bouncing? The failure modes
Most inbound failures are DNS, not code. Here are the errors you will actually see and what each one means.
The sender gets a hard bounce: "no MX record." DNS has no MX record for the domain, or it has not propagated yet. The bounce message looks like:
550 5.1.2 We weren't able to find the recipient domain's mail server.
Check dig +short MX yourdomain.com. If it returns nothing, the records are missing or you added them to the wrong zone (a common mistake is adding them on www.yourdomain.com instead of the apex @).
Mail goes to your old provider instead. A leftover lower-priority MX (Google's priority 1) is winning. dig MX will show both providers in the list. Delete the old provider's records.
Mail reaches Cloudflare but nothing arrives in the destination. The destination address was never verified, or the routing rule is disabled. Cloudflare does not bounce in this case; it accepts and drops. Verify the destination under Destination addresses.
The forward lands in spam. SPF is missing or your DMARC policy is rejecting the forwarded hop. Add the _spf.mx.cloudflare.net include. If you publish DMARC with p=reject, be aware that plain forwarding can break alignment; Email Routing's SRS handling mitigates this, but the SPF include must be present.
Records look right but mail still does not arrive. Propagation. DNS changes can take minutes to a couple of hours depending on the previous TTL. Query an authoritative resolver directly to skip your local cache:
dig +short MX yourdomain.com @1.1.1.1
If 1.1.1.1 shows the new records but your mail client still fails, you are waiting on TTL expiry elsewhere, not on a misconfiguration.
A note on the wall you will hit: Email Routing is inbound only
Worth being honest about before you build on this: these MX records let you receive. They do not let you send. Cloudflare Workers cannot open outbound port 25 for direct-to-MX SMTP, so the MX setup gives mail a place to land but no way to answer from the domain. If you reply from your personal Gmail, the reply comes from Gmail, not you@yourdomain.com. Sending from the domain needs a separate HTTPS-based sender; the why behind that wall is covered in why Workers cannot send email over SMTP.
Skip the DNS archaeology: let init publish the records
The manual path above is the right thing to understand, and you should: when mail bounces at 2am, knowing that MX priority is "lower wins" and that a stale Google record outranks Cloudflare's is what gets you unstuck. But once you understand it, typing the records by hand for every domain gets old, and the failure modes (wrong zone, leftover MX, unverified destination) are exactly the ones easy to fumble at a console.
The Tinbox email stack deploys to your own Cloudflare account and publishes this whole record set as part of init, then verifies it. It enables Email Routing, points the catch-all at an inbound Worker, provisions the D1 and R2 storage behind the inbox, and prints the exact records to add (including the DKIM record for the outbound sender, which the manual inbound-only setup never gives you):
npx tinbox init yourdomain.com
✔ Enabled Cloudflare Email Routing on yourdomain.com
✔ Configured catch-all -> inbound Worker
✔ Provisioned D1 database (tinbox-yourdomain-db)
✔ Provisioned R2 bucket (tinbox-yourdomain-mail)
Add these DNS records to yourdomain.com:
MX @ route1.mx.cloudflare.net (priority 13)
MX @ route2.mx.cloudflare.net (priority 86)
MX @ route3.mx.cloudflare.net (priority 24)
TXT @ v=spf1 include:_spf.mx.cloudflare.net ~all
TXT tinbox._domainkey v=DKIM1; k=rsa; p=MIIBIjANBg...
Once DNS propagates, run: npx tinbox doctor
npx tinbox doctor is the part that saves you the bounce hunt: it queries the live MX, SPF, and DKIM records, flags a leftover provider MX before it costs you mail, and tells you whether propagation is done:
✔ MX records resolve to Cloudflare Email Routing (3/3)
✔ No conflicting MX records found
✔ SPF include present
✔ DKIM record published and valid
✔ Destination verified
Inbound mail is live for yourdomain.com.
The MX records you just learned to set by hand are the foundation. Tinbox publishes them, checks them, and adds the outbound sender that pure Email Routing leaves out, so the domain becomes a working two-way inbox instead of a forwarding rule.
Where to go from here
- set up a catch-all address: once MX records get mail to Cloudflare, the catch-all decides where every address lands.
- send email from a Worker: the outbound half these MX records cannot provide, and how to close it.
- verify SPF, DKIM, and DMARC pass: confirm the records you just published actually authenticate at the receiver.
- the full Tinbox stack: inbound MX, storage, search, and an HTTPS sender on one Cloudflare deploy.
Deploy this yourself: npx tinbox init yourdomain.com. Full DNS and routing options are in the docs.
Frequently asked questions
What MX records do I need to receive email on Cloudflare?
Cloudflare Email Routing publishes three MX records pointing at route1.mx.cloudflare.net (priority 13), route2.mx.cloudflare.net (priority 86), and route3.mx.cloudflare.net (priority 24). These must be the only MX records on the apex of your domain. Add them when you enable Email Routing, then add the SPF TXT record (v=spf1 include:_spf.mx.cloudflare.net ~all) so forwarded mail passes alignment.
Why is mail bouncing or not arriving at my Cloudflare inbox?
The four common causes are: MX records missing or pointed at the wrong host; a leftover MX from a previous provider (like aspmx.l.google.com) that intercepts the mail first; Email Routing enabled but the destination address never verified, which drops mail silently; or DNS not yet propagated. Check the records with dig MX yourdomain.com and confirm only Cloudflare's three appear.
What does MX record priority mean and which one is used first?
MX priority is a preference number: lower is tried first. A sending server tries the lowest-priority MX, and only falls back to higher numbers if it cannot connect. Cloudflare's route1 (13) is preferred, with route2 (86) and route3 (24) as fallbacks. The exact numbers do not matter as long as all three are present and they are the only MX records on the domain.
Do I need SPF, DKIM, and DMARC just to receive email?
To receive, the MX record is what matters. SPF and DKIM exist so that mail you send (and mail Email Routing forwards on your behalf) passes authentication at the next hop. Cloudflare gives you an SPF include to add, and Email Routing handles SRS rewriting for forwarding. DMARC is optional for receiving but recommended once you also send from the domain.
Can I keep my Google Workspace MX records and add Cloudflare too?
No. A domain can only deliver inbound mail to one mail system at the apex, and mixing MX records from two providers produces ambiguous, unreliable delivery. To move receiving to Cloudflare you remove the existing provider's MX records and publish only Cloudflare's three. There is no supported split-MX arrangement.