mailflare README

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

Mailflare

Mailflare

A self-hosted alternative to Google Workspace: custom domain email, calendar, Drive, booking and built-in AI agents. For people and teams who want their own mail on Cloudflare, Docker or Vercel.

Don't want to manage a deployment? Try Mailflare Cloud, with high-deliverability email.

Deploy to Cloudflare Deploy with Vercel

Screenshots

Inbox
Inbox
Manage domains
Domains
Manage inboxes
Mailboxes
Calendar
Calendar
Booking
Booking
Drive
Drive

Features

Feature What you get
Email Personal or shared mailboxes on your domain, with access you control. Send and receive with Cloudflare Email, Resend or Amazon SES.
Routing rules Store, forward, reject or sort incoming mail, including one rule for newsletters and promotions.
Calendar Repeating events with time zones. Attendees get email invitations.
Booking A public link so anyone can book a free time on your calendar.
Drive Store and share files.
AI agents Search mail, draft replies and manage events. Connect other AI tools over MCP (Model Context Protocol).
Admin Users, API keys, webhooks, audit logs and backups.
Import Mail from IMAP, Gmail Takeout, .eml and .mbox. Calendar events, contacts and Drive files from Google Takeout.
Databases Cloudflare D1 (default), PostgreSQL, MySQL, Turso / libSQL or a SQLite file. Set DATABASE_URL to switch. Works with Supabase, Neon, PlanetScale, TiDB and more (databases).
File storage Cloudflare R2, Backblaze B2 or AWS S3.
Hosting Cloudflare Workers, one Docker container, or Vercel.

Mailflare supports 34 languages: English, Português (Brasil), Português (Portugal), Español, Français, Deutsch, Italiano, Nederlands, Polski, Українська, Русский, Türkçe, 中文(简体), 日本語, 한국어, Bahasa Indonesia, Bahasa Melayu, Tiếng Việt, ไทย, हिन्दी, বাংলা, मराठी, తెలుగు, தமிழ், ગુજરાતી, ಕನ್ನಡ, മലയാളം, ਪੰਜਾਬੀ, සිංහල, Kiswahili, Hausa, plus العربية, اردو and فارسی (right-to-left).

Cost

You can receive and send mail for free.

Task Service Price
Receive Cloudflare Email Routing Free
Send Resend Free tier: 3,000 emails a month
Send Amazon SES Free tier
Send Cloudflare Email Sending Needs the $5/month Paid Workers plan

New Amazon SES accounts start in a sandbox. Ask AWS for production access to lift it. Prices change, so check Resend, Amazon SES and Cloudflare.

Deploy to Cloudflare

You need:

Steps:

  1. Click Deploy to Cloudflare above. Keep the app name mailflare, or the app breaks.
  2. Add your CF_TOKEN when asked.
  3. Open the app at /setup and create your admin account.
  4. Add a domain from the same Cloudflare account.
  5. Create your first mailbox and send it a test message.

Details: Cloudflare guide. Problems: troubleshooting.

Self-host with Docker

Runs as one container on any server, with SQLite and local files.

git clone https://github.com/hieunc229/mailflare && cd mailflare
cp .env.docker.example .env.docker
docker compose up -d --build

Edit .env.docker first to set how mail is received and sent. To skip the build, use the prebuilt image: docker compose -f docker-compose.image.yml up -d.

Next: self-hosting guide.

Deploy to Vercel

Deploy with Vercel

Need Options
Database A hosted one, such as Turso from the Vercel Marketplace
Storage Vercel Blob (must be private; check the free limits), AWS S3 or Backblaze B2
Queues Vercel Queues (beta)
Receiving mail Email relay Worker, Resend or Amazon SES

The Hobby plan is for non-commercial use. After deploying, add the database and storage, then start the five-minute schedule. Keep the database in the same region as the functions, or first setup can take many minutes.

Next: Vercel guide.

Deploy with an AI agent

Paste this into an AI agent that has terminal access (Claude Code, Codex, Cursor and similar):

Install Mailflare for me from https://github.com/hieunc229/mailflare on my Cloudflare account.

1. Read README.md, docs/deploy-cloudflare.md and wrangler.jsonc first.
2. Ask me for my Cloudflare account ID and two API tokens, using a secret input:
   a deploy token (for Wrangler) and a runtime token (the Worker secret CF_TOKEN).
   Never print them, commit them, or pass them as command arguments.
3. Keep the Worker name exactly "mailflare". Create or reuse the D1 database
   "mailflare", the R2 bucket "mailflare-raw", and the queues "mailflare-inbound",
   "mailflare-outbound" and "mailflare-agent".
4. Install dependencies, run `npm run deploy`, and set CF_TOKEN as a Worker secret.
   Do not run remote database migrations yourself. The /setup page does that.
5. Give me the app URL and anything I still need to do. I will open /setup, create
   the admin account and connect my domain.

Token permissions: deployment guide.

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 localhost:3000.

Command What it does
npm run db:seed Load sample data (the app must be running)
npm run build Build the Worker
npm run deploy Build and deploy
npm run lint Lint

A schema change needs a migration for each database type. See migrations.

Documentation

Using Mailflare

Setup and reference

License

See LICENSE.

mailflare (hieunc229/mailflare)

Searching Database…

What is this?Mailflare is a self-hosted email inbox for custom domains, built on Cloudflare, with support for sending/receiving through Cloudflare, Resend, or Amazon SES.
Is this a Cloudflare Worker app or a Docker container I run on my own server?Both: it deploys as a Cloudflare Worker using D1 and R2, or it runs as a single Docker container on any server using SQLite and local files instead.
How do I deploy it?Click 'Deploy to Cloudflare' (keep the app name 'mailflare'), open the deployed app and follow /setup to create your admin account, then connect a domain and create your first mailbox.
What do I need from Cloudflare before deploying?You need a Cloudflare account with a domain, and a scoped CFTOKEN API token with Email Sending, DNS Settings, Email Routing Addresses, DNS, Email Routing Rules, and Zone Settings edit permissions.
Any catch with the Worker deployment name or sending costs?You must keep the deployed Worker named 'mailflare' or the app breaks, and sending mail through Cloudflare's own email service requires a paid Worker plan ($5/month) since there's no free tier for it.
Can I run it on a VPS instead of Cloudflare Workers?Yes, the Docker version runs as a single container on any server using SQLite and local files, with a built-in SMTP listener for inbound mail.
Where does my mail and attachments actually get stored?Your mail stays in your own Cloudflare D1 database and attachments stay in your own R2 bucket (or local SQLite/files in the Docker self-hosted version), regardless of which sending provider you use.
What's included besides email: does it have a calendar?Yes, Mailflare includes a calendar for scheduling recurring events with time zones and attendees, plus public booking pages so others can book free slots.
Can AI tools interact with my inbox?Yes, there's a built-in AI assistant to search mail, draft replies, and manage calendar events, plus MCP access so external AI clients can connect with scoped API key permissions.
How much does it actually cost to run?Receiving mail via Cloudflare Email Routing is free; sending is free using Resend's (3,000 emails/month) or Amazon SES's free tiers, while Cloudflare's own sending needs a $5/month paid Worker plan.
What admin controls are available?Admins can manage users, permissions, API keys, webhooks, audit logs, and backups, plus set routing rules to store, forward, reject, or sort incoming mail automatically.
Creator
hieunc229
Size
73.8 MB
Stars
7.8K
Updated
CommitNov 18
Age
6mo
Commits · 90 Days