mailflare README

The project's README from github.com/hieunc229/mailflare. As one markdown file: README.md.

Mailflare

Mailflare

Mailflare is a self-hosted email inbox for custom domains, built on Cloudflare. Supports Resend, or AWS SES

Deploy to Cloudflare

Screenshots

Inbox
Inbox
Manage domains
Manage domains
Manage inboxes
Manage inboxes
Sequenzy Drivemug

Want to support the mailflare? Start sponsoring

What you can do

How it works

Mailflare runs in your Cloudflare account. By default, Cloudflare Email Routing delivers incoming mail to the app, and Cloudflare's email service sends outgoing mail. Each domain can also receive or send through Resend or Amazon SES. Cloudflare still manages the DNS.

Your mail stays in your own D1 database, and attachments stay in your own R2 bucket, whichever provider you use. See Sending and receiving providers.

Cost

You can set up Mailflare, receive mail, and send mail for free. Receiving with Cloudflare Email Routing is free. For sending, use the free tier of Resend or Amazon SES. Cloudflare's own email sending needs a paid Worker plan.

Send with Free tier After that
Resend 3,000 emails a month (100 a day), 3 domains From $20/month for 50,000 emails
Amazon SES $200 AWS credit for new accounts (about 2 million emails). The free plan lasts 6 months and credits expire after 12. $0.10 per 1,000 emails
Cloudflare Email Sending None Needs a Paid Worker plan ($5/month)

Receiving costs:

New SES accounts start in a sandbox that only delivers to verified addresses. Request production access in the AWS console to lift this.

You choose the provider per domain and can switch anytime (see Sending and receiving providers). Prices change, so check Resend, Amazon SES, and Cloudflare first.

Deploy

  1. Deploy the app. Click Deploy to Cloudflare. Keep the app name mailflare. Other Worker names will break the app.
  2. Finish setup. Open the deployed app and follow /setup to check the install and create your admin account.
  3. Connect a domain. Add a domain from the same Cloudflare account and choose which service receives its mail. Mailflare sets up Email Routing, or guides you through Resend or Amazon SES. Then create your first mailbox. Add Resend or AWS credentials on the domain page when you need them.

⚠️ CF_TOKEN is required during deployment. Create a scoped Cloudflare API token with these permissions for the domains you want to connect:

Deploy with an AI coding agent

Paste the prompt below into an agent with terminal access. Give it your Cloudflare account ID and two separate scoped API tokens through the agent's secret input. Never put them in a public chat, repository, or committed file.

Install Mailflare from https://github.com/hieunc229/mailflare in my Cloudflare account.
Ask me for my Cloudflare account ID, a scoped deployment API token, and a separate
runtime CF_TOKEN through a secret input. Never print, commit, or place either token
in a command argument or a tracked file. Use the deployment token only for Wrangler
authentication (CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID).

Read README.md, docs/deployment.md, and wrangler.jsonc first. Keep the Worker name
exactly mailflare. In the selected account, create or reuse the D1 database
mailflare, R2 bucket mailflare-raw, and Queues mailflare-inbound,
mailflare-outbound, and mailflare-agent. Set the D1 database_id in the local
Wrangler config without committing that account-specific ID. Install dependencies,
run npm run deploy, and set the runtime CF_TOKEN as a Worker secret. Do not run
remote D1 migrations manually; the /setup flow initializes the database.

Give me the deployed URL and any remaining Cloudflare account actions. I will
open /setup, create the first admin account, and connect my domain there.

See the deployment guide for permissions, manual deployment, backups, and updates.

Self-host with Docker

Mailflare also runs as one container on any server. It uses SQLite and local files instead of D1 and R2.

cp .env.docker.example .env.docker
docker compose up -d --build

See docs/self-hosting.md.

Local development

cp .dev.vars.example .dev.vars
npm install
npm run db:migrate:local
npm run dev

Add your Cloudflare credentials to .dev.vars, then open http://localhost:3000. To load sample data, run npm run db:seed while the dev server is running.

The Cloudflare app uses vinext and the Cloudflare Vite plugin, with local D1, R2, Queues, and Durable Objects. Remote bindings are off by default. To use Workers AI locally, log in with Wrangler, set CLOUDFLARE_ACCOUNT_ID, and run CLOUDFLARE_REMOTE_BINDINGS=true npm run dev.

The Node/Docker runtime still uses Next.js with build:node, start:node, and dev:node.

Documentation

License

See LICENSE.

mailflare (hieunc229/mailflare)

Searching Database…

这是什么?Mailflare 是一个基于 Cloudflare 构建的自托管自定义域名邮箱,支持通过 Cloudflare、Resend 或 Amazon SES 收发邮件。
这是 Cloudflare Worker 应用,还是我能在自己服务器上跑的 Docker 容器?两者都可以:它既可以部署为使用 D1 和 R2 的 Cloudflare Worker,也可以作为单个 Docker 容器在任何服务器上运行,改用 SQLite 和本地文件。
怎么部署它?点击 'Deploy to Cloudflare'(保持应用名称为 'mailflare'),打开部署好的应用并按照 /setup 创建管理员账号,然后绑定域名并创建你的第一个邮箱。
部署之前需要从 Cloudflare 准备什么?你需要一个绑定了域名的 Cloudflare 账号,以及一个权限受限的 CFTOKEN API 令牌,具有 Email Sending、DNS Settings、Email Routing Addresses、DNS、Email Routing Rules 和 Zone Settings 的编辑权限。
Worker 部署名称或发信费用上有什么坑?你必须把部署的 Worker 命名为 'mailflare',否则应用会出问题;而且通过 Cloudflare 自家邮件服务发信需要付费 Worker 计划(每月 5 美元),因为它没有免费额度。
可以在 VPS 上运行而不是用 Cloudflare Workers 吗?可以,Docker 版本可以作为单个容器在任何服务器上运行,使用 SQLite 和本地文件,并内置用于接收邮件的 SMTP 监听器。
我的邮件和附件实际存在哪里?无论你使用哪家发信提供商,邮件都保存在你自己的 Cloudflare D1 数据库中,附件保存在你自己的 R2 存储桶中(Docker 自托管版本则使用本地 SQLite/文件)。
除了邮件还包含什么?有日历吗?有,Mailflare 内置日历,可以安排带时区和参与人的周期性日程,还提供公开预约页面,让别人可以预约你的空闲时段。
AI 工具能和我的收件箱交互吗?可以,内置 AI 助手可以搜索邮件、起草回复和管理日程,还提供 MCP 接入,让外部 AI 客户端能够以受限的 API key 权限连接。
实际运行起来要花多少钱?通过 Cloudflare Email Routing 收信是免费的;发信用 Resend(每月 3,000 封)或 Amazon SES 的免费额度也免费,而用 Cloudflare 自家的发信服务需要每月 5 美元的付费 Worker 计划。
有哪些管理员控制功能?管理员可以管理用户、权限、API key、webhook、审计日志和备份,还能设置路由规则,自动存储、转发、拒收或归类收到的邮件。
Creator
hieunc229
Size
67.4 MB
Stars
5.1K
Updated
CommitOct 19
Age
4mo
Commits · 90 Days