Skip to content

Dashboard deploy ​

Do not put secrets in GitHub. Fill private values in Cloudflare Settings.

Accounts ​

  1. Sign up for Cloudflare and GitHub
  2. Fork Xi-Mail
  3. Prepare an admin email (an external inbox is fine)
  4. Prepare two different random secrets, at least 32 characters each, for jwt_secret and init_secret

Fork the repository

You can deploy first and add a receiving domain later.

Create the project ​

  1. Cloudflare → Compute → Workers & Pages → Create → Create application
  2. Connect to Git → Continue with GitHub, then pick your fork
  3. Set the Worker name to xi-mail
  4. Leave Path, Build command, and Deploy command unchanged. The root wrangler.toml already defines the build
  5. Click Deploy and wait

Create an application and connect GitHub

If xi-mail already exists on this account, do not create another one. See Updates.

Runtime variables ​

Open xi-mail → Settings → Variables and Secrets and add:

TypeNameValue
TextadminThe full admin email you will register
Secretjwt_secretFirst random secret
Secretinit_secretSecond, different secret

Save and deploy. admin only marks the administrator; you still need to register with that address.

Runtime variables and bindings

Do not put these in Build variables. For authenticator 2FA later, add Secret two_factor_key.

Bindings ​

The root wrangler.toml creates D1 and KV. On the same Settings page confirm:

TypeVariableResource
D1dbxi-mail-db
KVkvxi-mail-kv

Keep the names db and kv.

Custom URL: Settings → Domains & Routes → Add → Custom domain.

Initialize ​

Open:

https://your-site/api/init/your-init_secret

When you see success, open the site and register with the admin email.

First login

The init URL contains a secret. If it returns 404, check that init_secret is on the live version and is at least 32 characters.

Receiving mail ​

  1. Xi-Mail → Settings → Domains, add and enable a suffix
  2. Cloudflare → Email Service → Email Routing, enable the domain and add MX / TXT
  3. Routing rules → Catch-all: change Drop to Send to a Worker, target xi-mail

Catch-all defaults to Drop

Send to a Worker

Choose xi-mail

A site hostname is not a mailbox suffix: binding mail.example.com does not receive mail for example.com.

After routing is connected, create a mailbox. The admin login is not a hosted inbox; add an address in the left list before mail can arrive.

Optional ​

FeatureWhere
OAuth loginAdmin OAuth settings
R2 / S3 attachmentsBind r2, or fill S3 in the admin UI
Cloudflare Email sendingBind Send Email as EMAIL, then enable it per domain
Sub-workerEnd of CLI, or Sub-worker

MIT License · Based on cloud-mail