Setup guide · cmail 0.4.0
From domain to inbox in 8 steps.
A few simple steps, in order. Tick each one when its Done when check passes. Your ticks are saved in this browser only.
cmail setup skips what is already done-
1
Check you have everything
- A domain you own, at any registrar.
- A free Cloudflare account.
- The inbox that should receive the mail (any provider).
- A second mailbox to send a test from.
- macOS or Linux (x86_64 or arm64), with
curlfor the installer or Homebrew (andgitonly if you install from a clone).
Already use this domain for a website or email? Note its DNS records now. You will copy them into Cloudflare in step 4.
Done when: you can log in to your registrar, Cloudflare and both mailboxes.
-
2
Install cmail
- Run the one-line installer. It downloads the cmail binary for your system, checks its SHA-256 checksum and installs it in
~/.local/bin. No sudo needed. - If it says
~/.local/binis not on your PATH, run theexport PATHline it prints. - Create your private config file and choose your addresses (default:
hello).
curl -fsSL https://raw.githubusercontent.com/luongnv89/cmail/main/install.sh | bash export PATH="$HOME/.local/bin:$PATH" cmail --version cmail config init cmail config set ADDRESSES hello,contactDone when:
cmail --versionprintscmail 0.4.0.$ cmail --version cmail 0.4.0 $ cmail config init Created private configuration: ~/.config/cmail/.env Next: cmail setup $ cmail config set ADDRESSES hello,contact
- Run the one-line installer. It downloads the cmail binary for your system, checks its SHA-256 checksum and installs it in
-
3
Create a Cloudflare API token
- Open My Profile → API Tokens → Create Token → Custom token → Get started.
- Give the token any name you will recognise, for example
cmail yourdomain.com. - Add the four permissions shown on the right.
- Account Resources: Include → the account that owns your domain.
Zone Resources: Include → Specific zone → your domain. - Create the token and copy it. You paste it in the next step.
Domain not on Cloudflare yet? Add it first (step 4) and keep this token. Only if you want
cmail setupto add the domain for you, set Zone to Edit and Zone Resources to All zones from an account → your account. Never choose All accounts or All zones.Never paste the token into chat, a web page or a screenshot. cmail asks for it with hidden input.
Done when: the token is created with all four permissions and copied somewhere private.
Create Custom Token · Permissions
All four rows are required. Simplified illustration. Scope Permission Access Zone Zone Read Zone Zone Settings Edit Zone Email Routing Rules Edit Account Email Routing Addresses Edit Account Resources · Include · your account
Continue to summary
Zone Resources · Include · Specific zone · your domain -
4
If needed: add your domain to Cloudflare
Only needed if your domain is not on Cloudflare yet. Already listed as Active under Domains in Cloudflare? Tick this step and go on:
cmail setupwill sayzone already active on Cloudflare.- Open the Cloudflare dashboard → Domains → Add a domain. Enter your domain and choose the Free plan.
- Check the DNS records Cloudflare found. Add any you still need (website, MX, TXT).
- Follow Cloudflare’s instructions to switch nameservers at your current registrar: turn off DNSSEC (remove DS records) first, then replace all nameservers with the two Cloudflare shows. Save.
Propagation can take up to 24–48 hours. You do not have to wait here: in step 5,
cmail setupchecks every 20 seconds for up to 20 minutes, and you can rerun it any time.Done when: your domain is listed in Cloudflare and your registrar uses Cloudflare’s two nameservers (Cloudflare may still show Pending for a while).
Beforens1.old-host.com
ns2.old-host.comAfter (yours will differ)ada.ns.cloudflare.com
bob.ns.cloudflare.comCloudflare assigned these nameservers to example.com: ada.ns.cloudflare.com bob.ns.cloudflare.com Before switching (services still using the old DNS host stop resolving otherwise): 1. Copy every DNS record you still need ... 2. Turn off DNSSEC at your registrar ... Then: 3. ... replace ALL nameservers with exactly the ones listed above. 4. Save. cmail now checks Cloudflare activation for up to 1200s.If the switch is not finished when you run setup, cmail prints the same nameservers and waits.
-
5
Run
cmail setupcmail setupAnswer two questions, then paste your token:
- Receiving inbox, e.g.
[email protected] - Your domain, e.g.
example.com
cmail then finds your domain on Cloudflare (or adds it, if it is not there yet and your token has Zone: Edit; see step 3), waits until it is active, enables Email Routing and adds a forwarding rule per address. It stops only when it needs you: nameservers still switching (step 4) or the verification email (step 6).
Want a preview first?
cmail setup --dry-runshows the full plan and any blockers. It changes nothing. It needs the token saved in your config first.Done when: setup is running past the token step. Keep the terminal open.
$ cmail setup ==> Setting up RECEIVING: your custom addresses will forward to an inbox you already use. ── Dependencies ── ● no external tools needed in manual registrar mode ── Configuration ── ? email address to receive forwarded mail (any provider): [email protected] ? domain you already own, at any registrar (e.g. example.com): example.com ── Cloudflare API token ── … token instructions, browser opens … ? paste Cloudflare API token: (hidden) ● Cloudflare token verified and saved to .env ── Cloudflare zone: example.com ── ● zone 9a7f…e21c — nameservers: ada.ns.cloudflare.com bob.ns.cloudflare.com ── Registrar nameservers: example.com ── ▲ zone is 'pending' — update the nameservers at your domain registrar yourself … see step 4 … ── Waiting for zone activation (nameserver propagation) ── status: pending — retrying in 20s ● zone active ── Enable Cloudflare Email Routing ── ● email routing enabled (Cloudflare routing DNS records added and locked) ── Destination address: [email protected] ── ▲ verification email sent to [email protected] — click the Cloudflare link still unverified — waiting (click the email link)… ● [email protected] verified ── Forwarding addresses (hello,contact -> [email protected]) ── ● [email protected] -> [email protected] ● [email protected] -> [email protected] Receiving is set up [email protected] -> [email protected] [email protected] -> [email protected] Elapsed time: 6m 41s (401 seconds)
Illustrative session, shortened. Your values and timing will differ.
- Receiving inbox, e.g.
-
6
Click the verification email
- Open your receiving inbox. Check Spam too.
- Open the email from Cloudflare and click Verify email address.
- Go back to the terminal. cmail notices within 15 seconds and finishes.
Done when: the terminal shows
Receiving is set up.Confirm that you want to receive email forwarded by Cloudflare Email Routing.
Verify email address -
7
Send yourself a test
- From a different mailbox, email
hello@your-domain. - Check it arrives in your receiving inbox (and Spam).
- Repeat for each address.
cmail listshows them all.
Done when: a test message arrives for every address.
$ cmail list Addresses on example.com (2): [email protected] -> [email protected] (verified) [email protected] -> [email protected] (verified) Catch-all (any other address): disabled -> drop
- From a different mailbox, email
-
8
Optional: send from your address
Sending is optional. Skip this if you only need to receive. It needs a Gmail account.
Google has announced it will remove third-party “Send as” starting January 2027. Check Google’s help first.
cmail send-as- Create a Google App Password (needs 2-Step Verification).
- Gmail → Settings → Accounts and Import → Send mail as → Add another email address.
- Enter the SMTP settings on the right. Confirm with the code Gmail emails to your new address.
Done when: a message sent “from” your address reaches another mailbox, or you skipped this step.
Add accountReplace what Gmail pre-fills. Simplified illustration. SMTP server smtp.gmail.com Port 587 Security TLS Username [email protected] Password App Password, not your Gmail password
All 8 steps checked
Congratulations, you are all set!
You ticked every step. Enjoy your custom address! If cmail saved you some time, please star the project on GitHub. It helps other people find it.
Stuck?
Setup stopped
Read the Setup stopped at: line, fix that step, then rerun cmail setup. Finished steps are skipped.
Check the state
cmail status shows zone, routing, destination and rules. cmail doctor checks tools, config and token.
Token errors
A 403 names the missing permission. Edit the token in Cloudflare, add it, and rerun setup.