Give every AI agent its own programmable inbox.
mails0 is an open-source email API for AI agents that need to receive messages, extract OTP codes, search inboxes, reply in threads, and run from CLI, SDK, or MCP tools.
Why agents need a real email API
A send-only API is not enough for autonomous agents. Agents sign up for services, receive verification codes, respond to threaded conversations, monitor operational alerts, and need a stable mailbox identity that can be audited and revoked.
OTP and confirmation links
Use mails code or the MCP wait_for_code tool to wait for new verification emails without hand-built IMAP polling.
Messages and replies
Agents can send updates, receive replies, preserve thread context, and keep mailbox-scoped credentials instead of using a human inbox.
Searchable memory
FTS5, semantic search, labels, and structured extraction make email usable as a retrievable agent work surface, not just a delivery pipe.
Agent email API requirements
| Requirement | Why it matters | mails0 support |
|---|---|---|
| Dedicated inboxes | Agents need separate identities and scoped access. | Mailbox-scoped API keys and hosted or self-hosted mailboxes. |
| Inbound receive | Signups, replies, and alerts arrive by email. | Cloudflare Email Routing ingestion with raw-first R2 storage. |
| Verification codes | OTP codes expire quickly and need deterministic retrieval. | mails code, Python wait_for_code, and MCP wait_for_code. |
| Search and context | Agents need to inspect old messages before acting. | Keyword, semantic, and hybrid search across stored mail. |
| Self-hosting | Agent email can contain credentials and sensitive workflow data. | MIT-licensed Cloudflare Workers deployment with D1 and R2. |
Start with the CLI, then wire it into your agent
The hosted mailbox is a quick sandbox with abuse controls. For production workflows, deploy mails0 to your own Cloudflare account and domain.
npm install -g mails-agent
mails claim myagent
mails config set mailbox [email protected]
mails inbox
mails code --to [email protected] --timeout 60
FAQ
How is this different from a transactional email API?
Transactional providers are strong at outbound delivery. Agent workflows also need inbound receive, mailbox search, verification-code extraction, thread context, and agent-scoped credentials. mails0 focuses on the full loop.
Can I use my own domain?
Yes. Self-host on Cloudflare, configure Email Routing for inbound mail, verify outbound sending, and point the CLI or SDK at your Worker URL.
What should I use for production?
Use the hosted mailbox to test the flow. Use self-hosted mails0 when you need custom domains, stricter data control, higher limits, or a production reputation boundary.