Mailworker
Your products send. Your agents read. You approve.
A self-hosted email runtime for AI agents, built on Cloudflare Email Service and Workers.
简体中文 · Quick start · REST API · CLI

Mailworker turns a Cloudflare domain into email infrastructure that both your
products and your AI agents can use. Applications get a Resend-like REST API for
transactional email. Agents get a CLI for creating inboxes, waiting for messages,
reading bodies, drafting replies, and submitting sends for human approval.
One deployment can serve multiple products and domains without a separate
Mailworker subscription for each one. The infrastructure, data, and credentials
stay in your Cloudflare account; Cloudflare plan and usage charges still apply.

Put email operations on an agent loop
| Your need | What Mailworker gives you |
|---|
| Email for every product | One REST API for transactional send and receive across multiple domains, with attachments, batch sends, webhooks, and delivery timelines |
| Agent-assisted support | Agents read untrusted mail as data, draft replies, and submit them to a queue; a human approves the irreversible send in the dashboard |
| E2E and manual testing | Create disposable inboxes on your own domain without creating a Cloudflare routing rule for every address; block until the message arrives and read its body |
| A control plane you own | Scoped API keys, agent identities, quotas, recipient allowlists, suppression handling, isolated environments, and a sandbox that sends nothing outside |
customer email ──▶ Cloudflare Email Routing ──▶ Mailworker ──▶ Agent reads + drafts
│
product API ─────▶ REST API / CLI ────────────▶ policy gates ──▶ human approves
│
recipient ◀────── Cloudflare Email Sending ◀── delivery queue ◀──────────┘
Deploy with one prompt
There is no hosted Mailworker account to sign up for. Clone the repository in a
coding-agent session and ask the agent to provision it into your Cloudflare
account:
git clone https://github.com/guangzhengli/mailworker.git
cd mailworker
pnpm install
Deploy this project to my Cloudflare account.
The bundled deploy-mailworker skill walks through four gated phases —
environment, discovery, plan, and execute. It changes nothing before you
approve the plan. The plan covers D1, R2, Queues, a Durable Object, the Worker,
Email Routing, Email Sending, delivery events, DNS, and the bootstrap admin key.
If your agent does not discover repository-local skills automatically, install
the deployment skill explicitly:
npx skills add guangzhengli/mailworker -s deploy-mailworker
You can also read every deployment step in
.agents/skills/deploy-mailworker/
and run it by hand.
Give agents an inbox
Install the public Mailworker skill in Codex, Claude Code, Cursor, or another
Agent Skills-compatible agent:
npx skills add guangzhengli/mailworker
Or use the CLI directly without cloning this repository:
npx @mailworker/cli@latest help --agent
An end-to-end signup test is two operations:
id=$(mailworker inbox create --prefix signup --ttl 10m --json | jq -r .id)
# Trigger the signup flow, then wait. stdout contains only the body.
BODY=$(mailworker wait --inbox "$id" --text --timeout 60s) || exit $?
Creating an inbox is one database insert, not a Cloudflare API call or a new
routing rule. Create one per test, expire it automatically, save a failed message
as raw .eml, and replay it through the same ingest path later.