Cloudflare will not let you proxy an MX record — the record type has no cloud toggle — but it happily lets you proxy the A record the MX points at, and that breaks mail just as thoroughly. A proxied mail.example.com resolves to Cloudflare anycast IPs, and those IPs carry HTTP and HTTPS only: connections to port 25 go nowhere. Senders defer, retry for a few days, then bounce with “connection timed out”. The fix is one click — flip the record to DNS-only — and the whole point of this article is recognizing the pattern in minutes instead of after the bounces start.
What’s happening
The orange cloud is an HTTP reverse proxy, not a general-purpose tunnel. When a record is proxied, Cloudflare answers DNS queries for it with edge IPs from its own ranges and forwards web traffic to your origin. Anything that is not HTTP or HTTPS — SMTP on 25 and 465/587, IMAP on 143/993, POP3 on 110/995 — is simply not carried (Spectrum, an Enterprise product, is the exception, and it is not what a standard zone does).
So the failure chain looks like this: a sending server resolves your MX, gets mail.example.com, resolves that name, receives 104.16.x.x instead of your server, attempts port 25, and the connection is refused or times out. The message goes back into the sender’s queue with a temporary failure and retries on a schedule; after the queue lifetime (commonly three to five days) it bounces permanently. That delay is why the proxied-MX mistake is often discovered a day or two after the change that caused it — mail did not visibly fail at first, it just went quiet.
The same toggle also breaks mail clients: if users’ IMAP/SMTP settings point at the proxied hostname, Outlook and Thunderbird start throwing connection errors even though webmail (an HTTP app) may still load fine through the proxy. The Cloudflare dashboard warns when an MX points at a proxied name — the warning is easy to dismiss during a busy migration, and dismissing it is exactly this incident.
What to check first
- What the MX target resolves to. If the IPs belong to Cloudflare, you have found it.
- The proxy status in the dashboard. DNS, find the A/AAAA/CNAME record for the MX target and for any
imap./smtp.hostname — orange means broken for mail. - When the record changed. The Cloudflare audit log dates the toggle; match it against when mail went quiet.
- Whether webmail still works while clients fail. That contrast is the signature of a proxied mail hostname.
How to verify
# Where is mail supposed to go, and what does that name resolve to?
dig +short MX example.com
dig +short A mail.example.com
dig @1.1.1.1 +short A mail.example.com
# Cloudflare publishes its edge ranges — compare what you got
curl -s https://www.cloudflare.com/ips-v4
An answer inside those ranges (commonly 104.16.0.0/13, 172.64.0.0/13) proves the record is proxied. Confirm SMTP is unreachable, then that the origin itself is fine when addressed directly:
# Through the published name — will hang or be refused if proxied
openssl s_client -connect mail.example.com:25 -starttls smtp -brief
# Straight at the origin IP — should show a 220 banner
openssl s_client -connect 203.0.113.25:25 -starttls smtp -brief
# Or a scripted delivery attempt
swaks --to user@example.com --server 203.0.113.25
On the server, the mail log goes silent for inbound during the incident — tail -f /var/log/exim_mainlog (or /var/log/maillog) shows no accept lines from outside senders, because their connections never arrive.
The fix
- Flip the record to DNS-only. In the Cloudflare dashboard: DNS, edit the A record for
mail.example.com, click the orange cloud so it turns grey, save. That is the entire fix for the record itself. - Sweep the zone for the rest of the mail path. Any hostname clients or servers connect to for mail —
smtp.,imap.,pop., the MX target on other domains in the account — must be grey. A webmail-only hostname can stay proxied, because webmail is HTTP. - Wait out the TTL. Proxied records carry a 300-second TTL, so the world picks up the origin IP within minutes. Re-run
dig @1.1.1.1 +short A mail.example.comuntil it returns your server. - Prove it end to end. The
openssl s_clientbanner through the hostname, then aswaksdelivery, then the accept line in the mail log. - Let deferred mail drain. Senders that queued during the outage retry on their own; anything younger than their queue lifetime arrives without action on your side.
When this fix is wrong
If dig already returns the origin IP, the proxy is not your problem — look at the host firewall, the provider’s port-25 policy, or the mail service itself being down. And if the reason someone proxied the record was to hide the origin IP from attackers, understand the trade: a grey-clouded mail record publishes that IP. The correct answer to that concern is moving mail to a separate IP or host, not re-proxying the record — see the mail subdomain strategy for the pattern.
Common mistakes
- Orange-clouding
mail.example.com“for protection” during a security pass, then dismissing the MX warning. - Pointing the MX at the apex or
www— hostnames that are proxied for good reasons — instead of a dedicated grey mail name. The MX-vs-A-record mistake covers that variant. - Fixing the MX target but forgetting the
smtp./imap.names clients use. - Testing only webmail, concluding “mail works”, and closing the ticket.
- Blaming the mail server and restarting services while the DNS answer was the whole story.
Prevention
Adopt a zone convention: every hostname whose job involves a non-HTTP protocol is DNS-only, permanently, and the dashboard warning about MX targets is treated as a release blocker. Audit after every import — Cloudflare’s DNS documentation spells out proxy eligibility per record type, and the record cookbook is our short version of the same rules.
Mail that breaks after a DNS move is one of the most common incidents we untangle — Stack Harbor manages the full DNS and mail path under Managed Cloud Ops; book an infrastructure review before the next migration.