To send and receive domain email directly on a website, the traditional approach is to install Postfix on the server, open port 25, and configure SPF/DKIM — high maintenance costs, and bounced messages are hard to diagnose. X1's Mail module takes a different approach: use Cloudflare Email Routing to receive mail, and a Worker to forward it to the site endpoint, so the server does not need to open a single mail port.

1. First distinguish the two mail settings
| Purpose | Location |
|---|---|
| System email (verification codes, notifications) | Settings → Mail (/admin/settings/notify/mail) |
| Mail module (Inbox, mass email) | Mail → Inbox → Settings (/admin/mail/settings) |
Recommended order: configure system email first to ensure verification codes and notifications can be sent; then configure Cloudflare receiving; when you need to pull mail from Gmail, 163, QQ, or Outlook, fill in IMAP/SMTP according to the provider.
2. Four steps to receive mail with Cloudflare
- Enable Email Routing: Cloudflare dashboard → Email → Email Routing. On first entry, add a destination address and click the verification link in the email — this address is only used for Cloudflare forwarding verification, not your inbox.
- Confirm MX: When the domain is hosted on Cloudflare, MX and SPF are usually added automatically; for external DNS, manually add
route1/2/3.mx.cloudflare.netwith priorities 10/20/30. Usedig MX your-domain +shortto confirm. - Create a route: To receive only a specific address, use “Create address” (e.g.
support@example.com); to receive all, enable Catch-all. For the action, select “Send to Worker”. - Create a Worker: Workers and Pages → Create Worker, copy the entire “Worker script” from “Advanced” in the admin, replace the default code, and deploy.
The script reads two environment variables: INBOUND_URL (the inbound address shown in the admin, in the form https://example.com/api/v1/mail/inbound) and INBOUND_KEY (Secret type, value from the “Inbound key” in the admin). After filling them in, redeploy for them to take effect.

3. Three constraints you must know
- 24 MiB limit: Workers and the inbound endpoint both reject emails over 24 MiB (including attachments); compress or split them.
- Existing enterprise mailbox on the same domain: Do not directly overwrite the existing MX records; either set Cloudflare's MX to a higher priority, or only use Cloudflare to receive mail for a subdomain.
- When changing the key, sync the Worker: After clicking “Regenerate” in the admin, the old key immediately becomes invalid; you must update the Worker's
INBOUND_KEYright away, otherwise all requests return 403.
4. Testing and troubleshooting
Send a test email from an external mailbox to the route address, then check three places in order: whether Cloudflare “Email Routing → Activity” shows successful forwarding with no errors; whether the Worker “Logs” contain 403, 503, or 413; whether the email appears in the KingCMS inbox. Incoming mail that cannot be matched to a recipient address goes to the default mailbox.
You can also test the endpoint directly: the correct key returns OK, an incorrect key returns 403, and if the module is not enabled or no key has been generated, it returns 503. These three status codes are usually enough to locate which layer the problem is in.
5. Common pitfalls
- The Worker is created under a different Cloudflare account: it must be under the same account as the receiving domain.
INBOUND_URLis set to localhost: it must be a publicly accessible HTTPS address.- The inbound address or key was changed in the admin but the Worker variables were not updated: this shows up as persistent 403s.
- Expecting emails to be marked as read automatically: they are not; the unread count is shown in the left menu.
- Pasting the key into a support ticket or chat: don't. The key is not displayed after saving; if leaked, the only option is to regenerate it.
Summary
The value of this approach is replacing “mail server operations” with “Cloudflare Routing + one Worker”. The setup order is: enable routing, confirm MX, create rules, create the Worker, configure the two variables, and send a real test email; in daily use, you only need to remember the 24 MiB limit and key synchronization.