In previous articles, I introduced how to host domains on Cloudflare and use CF CDN for free. This time, I’m demonstrating one of my favorite features: Email Routing. With just one domain, you can have your own domain email and create infinite sub-emails for use.

You don’t need to set up a complex mail server. As long as you have a domain hosted on Cloudflare, you can use any prefix to register accounts. All emails will be automatically forwarded to your designated primary email address, making it very convenient to receive verification codes.

Powerful Open Source Repository

Before we start the configuration, let me introduce an open-source repository that collects many projects deployed using free Cloudflare resources: Awesome Cloudflare.

Project Address

image

This repository collects many free open-source tools built with Cloudflare. If you’re interested or need to build small tools, you can check there first.

image

If you don’t even want to use your real email to receive forwards, you can find related projects in this repository, such as open-source projects using Cloudflare Workers to build temporary emails (e.g., vmail, smail, etc.).

image

By using these open-source projects, you can even build a dedicated temporary mail server at zero cost. Once you have a receiving address, we can start configuring the domain email routing.

Enable Email Routing

First, log in to the Cloudflare dashboard. In your domain list, find the domain you want to use for email.

image

In the sidebar menu, find “Email” and click “Email Routing”.

image

Upon entering the page, my routing feature is disabled because I turned it off earlier. If you’re new, it might look different, but the process is similar. Select the domain you want to use and click “Enable Email Routing”.

image

You won’t need to worry about DNS records (MX and TXT records) because Cloudflare will automatically fill them in for you. Just click save.

image

Configure Catch-all

Next, you need to bind a primary email (destination address) to receive all sub-emails. After binding, the system will send a verification email to that destination address.

You can also set up one-to-one mappings, like A@cc.com to A@bb.com. I’m using “Catch-all” for convenience to forward everything to one mailbox.

image

Open your mailbox and find the verification email from Cloudflare. Click “Verify email address” to complete the authorization.

image

After verification, return to the Cloudflare Email Routing settings page and find the “Catch-all address” setting. Click Edit and configure as follows:

  1. Action: Select “Send to email”
  2. Destination: Select the primary email you just verified (e.g., no-reply@legacyvps.com)

image

After saving, the core configuration is complete.

“Catch-all” literally means capturing everything. All emails ending in @yuhuiculture.icu, regardless of the prefix (e.g., a@, 123@, test@), will be forwarded to your primary set mailbox.

Testing Sub-emails

I’ll demonstrate using DMIT and Discord services, using two different sub-emails. Both results show up in the primary mailbox.

Test 1: Discord Registration

image

image

Test 2: DMIT Registration

image

image

Testing shows that standard email registration services work fine, and verification codes can be received. If combined with an API that can directly fetch email content, think about the freedom it offers.

Important Notes

With Cloudflare’s Email Routing, all we need is a domain hosted on Cloudflare to achieve custom domain freedom, no matter how many domains we have.

However, keep these points in mind:

  1. Since they share the same domain suffix, being too aggressive could lead to all your emails being banned collectively. Manage your risks.
  2. The domain needs renewal. If you forget to renew and someone else registers it, your associated emails belong to them.
  3. It currently only provides receiving features. Sending features are in beta, and hopefully, Cloudflare will provide a full email service soon.