Minimalist responsive email service based on Cloudflare, supports sending emails and attachments

Github repository address:

https://github.com/maillab/cloud-mail

Feature Overview

  • :money_bag: Low Cost Usage: Can be deployed on Cloudflare Workers to reduce server costs
  • :laptop: Responsive Design: Responsive layout automatically adapts to PC and most mobile browsers
  • :e_mail: Email Sending: Integrated with Resend for sending emails, supports mass mailing, embedded images and attachments, and viewing send status
  • :shield: Admin Features: Manage users and emails, RBAC (role-based access control) for feature and resource usage restrictions
  • :package: Attachments Support: Send and receive attachments, save and download files with R2 object storage
  • :bell: Email Forwarding: Incoming emails can be forwarded to a TG bot or other providers’ mailboxes
  • :satellite_antenna: Open API: Supports batch user creation via API, multi-condition email queries
  • :chart_increasing: Data Visualization: Use ECharts to visually display system data details and growth of user email usage
  • :artist_palette: Customization: Customize website title, login background, and transparency
  • :robot: Human Verification: Integrated Turnstile captcha to prevent mass bot registrations

Setup Guide: YouTube video, also where I discovered this project

https://www.youtube.com/watch?v=3nzW1PUbkDs


Setup Guide: Text Summary Version

Prerequisites

  1. A CF (Cloudflare) account https://www.cloudflare.com
  2. A domain already hosted on CF
  3. Resend account https://resend.com

Steps

  1. Go to the Github repository and Fork this project (If you find this project great, please support the author :star: )

  2. In CF, create both a D1 database and a KV namespace (names can be anything)

  3. In CF, create a Workers project (Continue with Github, select the project you just forked. First time users need to link their Github account). On the deployment screen, scroll down to Advanced Settings, expand, and set the Route to /mail-work

  4. Add a custom domain for this project (must be a domain already added to your CF account, e.g.: mail.example.com)

  5. Add environment variables

Mail Domain:

Type: JSON
Variable Name: domain
Value: [“your custom domain’s root, e.g.: example.com”] *Make sure to use English brackets and quotation marks

Admin Account:

Type: Text
Variable Name: admin
Value: Your desired admin email, e.g.: [email protected]

Security Key Variable:

Type: Text
Variable Name: jwt_secret
Value: A combination of letters and numbers, e.g.: abc456xyz *The security key must not contain special characters

  1. Bind KV namespace and D1 database

KV Namespace

Variable Name: kv *Lowercase only
KV Namespace: Select the KV namespace you just created

D1 Database

Variable Name: db *Lowercase only
D1 Database: Select the D1 database you just created

  1. Set up email routing
  • On the CF main page, click your domain (example.com) => In the left menu, go to Email => Email Routing => Get Started (for first time setup, click Skip onboarding guide) => At the top of the page, click Enable Email Routing => Scroll down and click Add records and enable
  • On the Email Routing page, click Routing Rules => Edit the Catch-All rule => For Action select Send to Worker => For Target select the Workers project you just created => Click Save
  • Ensure the Catch-All rule is Active
  1. Initialization
    In your browser, visit: your custom domain/api/init/your security key *e.g.: mail.example.com/api/init/abc456xyz If you see SUCCESS on the page, initialization was successful

  2. Login and Receiving Mail
    Now, visiting your custom domain will show the mailbox login/registration page. Use Sign up to register the admin email you set and set a login password for it. After registering, return to the mailbox login page to log in and start receiving emails with your admin account.

  3. Resend Setup & Sending Mail

  • Log in to your Resend account and add your mail domain (example.com) on the Domains page, wait for DNS verification (Auto configure) to complete
  • On the API Keys page in Resend, create your API key (Create API key), set the key name/permissions, copy the API Key *Note: it is only displayed once, make sure to save it
  • Set mail delivery status alerts in the Webhooks page: click Add Webhooks, in Endpoint URL enter https://mail.example.com/api/webhooks, in Events types tick under the Email section: email.bounced (bounced), email.complained (complained), email.delivered (delivered), email.delivery_delayed (delivery delayed), email.failed (failed). The rest are not recommended.
  • Go back to the mailbox page, select System Settings, in the Email section under Resend Token click + to add the API Key you just obtained from Resend; you can now send emails normally.
8 Likes

You’re using email routing, right? If you don’t want to host your domain on CF, you can’t use it.

A newcomer here to learn

Thanks for sharing

Yeah, that’s right~

If you don’t host with CF, using serv00’s email system is pretty good—I’m using it myself.

Or you could use WeCom (Enterprise WeChat)'s email too, but the only thing is it limits how many email accounts you can create.

I’m using SERV00 and it’s pretty good.

This method works too, but I’ve already deployed it. Still, I’m here to show my support~

I deployed this one a while ago and have been using it for several months. It’s pretty good.

Study, study

Let’s learn together!

Domain email is great for receiving messages.

vps8 supports email routing


I found out that I can log in and receive emails on the ninth attempt, but this message pops up and I can’t get into the mailbox login page. Could someone help me fix this? The initialization already showed “success”.

Didn’t you set the domain environment variable when you deployed?

Typed the wrong letter :xhj24:

1 Like