DEV Community

Cover image for Get Every Email to Your Domain in One Gmail Inbox, Free, with Cloudflare
Sid Probstein
Sid Probstein

Posted on

Get Every Email to Your Domain in One Gmail Inbox, Free, with Cloudflare

You own a domain. Your website lives on it. With Cloudflare's free plan you can make anything@yourdomain.com - any address, invented on the spot - land in your regular Gmail inbox. No Google Workspace subscription, no mail server, no changing registrars. About 30 minutes, $0.

What you get:

  • A catch-all: every address at your domain forwards to one inbox.
  • Free disposable addresses: give netflix@yourdomain.com to Netflix and bank@yourdomain.com to your bank. When spam arrives addressed to one of them, you know who leaked your address.
  • Your website, untouched.

One limitation: this is receive-only. You can reply as you@yourdomain.com from free Gmail via "Send mail as", but the mail goes out through Google's servers without your domain's blessing, so some recipients see "via gmail.com" and strict spam filters may object. If sending from the domain matters, that's what Google Workspace is for. For receiving, read on.

You need: a domain (registered anywhere; it stays there), a free Cloudflare account, and an inbox to receive the mail.

Step 1: Add your domain to Cloudflare

Log in at dash.cloudflare.com, click Add a domain, pick the Free plan.

Cloudflare scans your existing DNS and imports what it finds. Review this list carefully - the scan is good but not guaranteed complete, and whatever it misses stops resolving after the switch. Check what your DNS really says from any terminal:

dig +short A yourdomain.com
dig +short MX yourdomain.com
dig +short NS yourdomain.com
Enter fullscreen mode Exit fullscreen mode

If the MX query returns nothing, you have no existing email service and this migration is pure upside. If it returns something, understand what that mail service is before proceeding.

Step 2: The gotcha - where does your DNS actually live?

That NS query tells you who currently answers DNS for your domain, and it is not always your registrar.

In my case the nameservers pointed at NS1 (*.nsone.net) - Netlify DNS. My registrar just held the registration; the DNS zone lived in Netlify, from clicking "use Netlify DNS" when connecting my site years earlier. The A records Cloudflare imported were Netlify load balancer IPs, which Netlify rotates. Had I switched nameservers and kept those records, my site would have broken on the next rotation.

The fix: point at names, not IPs. For a Netlify site (same idea for Vercel, GitHub Pages, and friends):

  1. Find your site's default subdomain in the Netlify dashboard (your-site.netlify.app).
  2. In Cloudflare's DNS page, delete the imported A records.
  3. Add two CNAMEs, both DNS only (click the orange cloud so it turns grey):
    • wwwyour-site.netlify.app
    • @ (apex) → your-site.netlify.app (Cloudflare flattens apex CNAMEs automatically)

DNS-only matters. Your host already runs a CDN and manages your HTTPS certificate; stacking Cloudflare's proxy in front invites redirect loops and cert renewal failures for zero benefit. Grey cloud means Cloudflare only answers DNS. Email Routing doesn't use the proxy, so it works either way.

Step 3: Switch nameservers at your registrar

Cloudflare assigns you two nameservers, like ada.ns.cloudflare.com and bob.ns.cloudflare.com. At your registrar, replace the current nameservers with those two. The registrar keeps the registration and the renewal bill; it just stops answering DNS questions.

Propagation is faster than its reputation - the change hits the .com registry within minutes:

dig +noall +authority NS yourdomain.com @a.gtld-servers.net
Enter fullscreen mode Exit fullscreen mode

When that shows the Cloudflare nameservers, click Check nameservers now on your domain's Cloudflare overview page instead of waiting for its periodic poll. Then load your website. If you did Step 2 right, nothing changed.

Step 4: Turn on Email Routing

In the Cloudflare dashboard for your domain: Email → Email Routing → Get started.

  1. Add a destination address - your Gmail. Click the link in the verification email Cloudflare sends.
  2. On Routing rules, enable the Catch-all with action "Send to an email" pointed at your verified destination.
  3. Accept the DNS records Cloudflare offers to add: three MX records (route1/2/3.mx.cloudflare.net) that direct your domain's mail to Cloudflare, plus SPF and DKIM records that keep forwarded mail from being spam-flagged. The odd-looking MX priorities are normal.

That single catch-all rule is the whole feature.

Step 5: Test it

dig +short MX yourdomain.com
# 36 route3.mx.cloudflare.net.
# 95 route2.mx.cloudflare.net.
# 98 route1.mx.cloudflare.net.
Enter fullscreen mode Exit fullscreen mode

Send a message from an account other than the destination inbox (Gmail hides mail you send to yourself) to an address you just made up: whatever@yourdomain.com. It should arrive within seconds. Check spam the first time and hit "Not spam" if needed.

Caveats

  • Receive-only, as covered above. Email Routing forwards; it doesn't send or store.
  • Catch-alls attract spam eventually - dictionary-attack spam to random@yourdomain.com all lands on you. Gmail's filtering handles it, and the per-service trick turns the bug into a feature: add a Cloudflare rule to drop any address that gets burned.
  • Your old DNS host's features die at the switch - web redirects, parked pages, registrar email forwarding. That's the point, but inventory what you use before you flip.

Half an hour, zero dollars, and every address at your domain lands in one inbox.

Top comments (0)