Cloud Mail builds its own mailbox platform

A WebMail (Mailbox System) solution based on Vue3 and Cloudflare Workers can self-host mailbox functions without the need to build a self-built server.
The main functions include: sending attached emails, receiving emails, mailbox management, R2 storage, D1 database, KV cache, Turnstile verification, group sending, TG push, etc.

Quick Getting Started Guide

1. Clone warehouse installation dependency

git clone https://github.com/LaziestRen/cloud-mail.git
cd cloud-mail/mail-worker
npm install

2. Configure Cloudflare environment

  • wrangler.toml Fill in:
    • The binding name and ID of KV, D1, and R2 (copy and fill in after creating relevant resources).
    • domain(Your email domain is as follows example.com)、jwt_secret(custom key), administrator mailbox and other variables.
  • The deployment process relies on Cloudflare Workers, KV, D1, and R2:
    1. Create these resources in the Cloudflare console;
    2. fill in wrangler.toml;
    3. implementation npm run deploy

3. DNS and mail routing settings

  • Domain name resolution points to Cloudflare Workers.
  • Set up email routing in the Cloudflare console to forward all messages (Catch-all) to /api Worker。

4. initialize the database

After deployment, visit the following URL to initialize D1 and KV:

https: Your domain name/api/init/your_jwt_secret>

5. Configure Resend email forwarding service

  1. Register Resend, add domain names and verify;
  2. Obtain API Token and configure it to the mailbox system backend;
  3. Set the Webhook address to https://Your domain name/api/webhooks, and check the relevant email event.

6. local development environment

You can simulate actual deployment locally:

npm run dev
#Then visit http://127.0.0.1:8787/api/init/your_secret initialization
#In configuration, you can use the local address to upload attachments (such as http://127.0.0.1:8787/api/file)

Project structure technology stack

  • Front-end (mail-vue):Vue3 + Element Plus
  • Back-end (mail-worker):Hono、Drizzle ORM、Cloudflare Workers
  • Storage, etc.: Cloudflare KV, R2, D1; Email sending: Resend; Attachment receiving and receiving: R2; Man-machine verification: Turnstile

Summary of operating steps (flow chart)

stepdescribed
clone warehouseTake down the code and install dependencies
allocation of resourcesSet up Cloudflare resources and fill in wrangler.toml
Deploy Workersnpm run deploy Deploy backend to Cloudflare
Set up DNS resolution and mail routingEnable domain names to receive emails and forward them to workers
initialize the databaseby /api/init/... Initialize backend storage
Configure mail servicesResend and Webhook complete integration
Login to the Web interfaceUse the administrator mailbox to log in to the management backend

💡Tips

  • Before deployment, ensure that DNS is resolved and Cloudflare management is turned on (Workers routing is in effect).
  • Resend registration and domain name verification may take a while.
  • The Cloudflare free plan has usage restrictions on Workers, D1, R2, etc., and is suitable for individual or small-scale use.
  • If you want to debug locally, remember to visit locally /api/init/... Initialize.

Github:https://github.com/eoao/cloud-mail

Oil tubing:

Scroll to Top