loading…
Search for a command to run...
loading…
Real email and SMS for AI agents. Run a local mail server with disposable inboxes — agents send and receive real email, fetch verification codes, and drive a re
Real email and SMS for AI agents. Run a local mail server with disposable inboxes — agents send and receive real email, fetch verification codes, and drive a real inbox without going through any third-party email API.
The first platform to give AI agents real email addresses and phone numbers. Send and receive email, SMS, and verification codes — all programmatically.
Structured RPC vs. Text-Based Sub-Agent Orchestration — A comparative analysis of inter-agent communication paradigms. Demonstrates why AgenticMail's call_agent achieves 53× faster response times than conventional sub-agent spawning, and introduces the concept of the Conversational Fallacy in multi-agent AI systems. [PDF] [Source]
AgenticMail is a self-hosted communication platform purpose-built for AI agents. It runs a local Stalwart mail server via Docker, integrates Google Voice for SMS/phone access, exposes a REST API with 75+ endpoints, and works with any MCP-compatible AI client and OpenClaw via plugin. Each agent gets its own email address, phone number, inbox, and API key.
AI agents need to communicate with the real world. Email is the universal communication protocol — every person and business has an email address. AgenticMail bridges the gap between AI agents and email by providing:
call_agent replaces basic sub-agent spawning with auto mode detection, dynamic timeouts, runtime tool discovery, and async execution for long-running tasks.agenticmail update checks npm, verifies OpenClaw compatibility, and updates both packages automatically.@localhost[email protected]. Setup takes 2 minutes.[email protected] with full DKIM signing, SPF, and DMARC records.@domain email alias for all existing agentsPOST /mail/pending/:id/approve)agenticmail update or /update in shell, with OpenClaw compatibility check ┌──────────────────────────────────────────────────┐
│ AgenticMail │
│ │
AI Client ─MCP─> │ @agenticmail/mcp (62 tools, stdio transport) │
│ │ │
OpenClaw ─────> │ @agenticmail/openclaw (63 tools, plugin) │
│ │ │
HTTP clients──> │ ▼ │
│ @agenticmail/api (Express, 75+ endpoints) │
│ ├── Authentication (master key + agent keys) │
│ ├── Rate limiting (per-endpoint) │
│ ├── SSE streaming (real-time inbox events) │
│ └── Spam filter + Outbound guard │
│ │ │
│ ▼ │
│ @agenticmail/core (SDK layer) │
│ ├── AccountManager (CRUD agents in Stalwart) │
│ ├── MailSender (SMTP, nodemailer) │
│ ├── MailReceiver (IMAP, imapflow) │
│ ├── InboxWatcher (IMAP IDLE → events) │
│ ├── GatewayManager (relay + domain routing) │
│ │ ├── RelayGateway (Gmail/Outlook) │
│ │ ├── CloudflareClient (DNS, tunnels, etc) │
│ │ ├── TunnelManager (cloudflared) │
│ │ ├── DNSConfigurator (MX, SPF, DKIM) │
│ │ └── DomainPurchaser (Registrar API) │
│ ├── StalwartAdmin (mail server management) │
│ ├── EmailSearchIndex (FTS5 full-text search) │
│ └── Storage (SQLite + migrations) │
│ │ │
│ ▼ │
│ Stalwart Mail Server (Docker container) │
│ ├── SMTP (port 587) — submission │
│ ├── SMTP (port 25) — inbound delivery │
│ ├── IMAP (port 143) — mailbox access │
│ └── HTTP (port 8080) — admin API │
└──────────────────────────────────────────────────┘
│ │
┌─────────────┘ └──────────────┐
▼ ▼
Relay Mode Domain Mode
┌──────────────────┐ ┌──────────────────────┐
│ Gmail / Outlook │ │ Cloudflare │
│ IMAP polling │ │ ├── DNS zone │
│ SMTP relay │ │ ├── Tunnel │
│ Sub-addressing │ │ ├── Email Routing │
│ (+agent@gmail) │ │ ├── Email Worker │
└──────────────────┘ │ └── Registrar │
└──────────────────────┘
Sending email (relay mode):
POST /mail/send with recipient, subject, body[email protected]Sending email (domain mode):
POST /mail/sendagent@localhost → [email protected]Receiving email (relay mode):
X-AgenticMail-Relay: inbound header added for identificationReceiving email (domain mode):
[email protected]/api/agenticmail/mail/inboundnpm install -g @agenticmail/cli
# 1. Start the mail server
docker compose up -d
# 2. Run the setup wizard (creates config, initializes database, creates first agent)
agenticmail setup
# 3. Start the API server + interactive shell
agenticmail start
The setup wizard will:
import { AgenticMailClient } from 'agenticmail';
const client = new AgenticMailClient({
apiUrl: 'http://127.0.0.1:3100',
apiKey: 'ak_your_agent_api_key',
});
// Send an email
await client.send({
to: '[email protected]',
subject: 'Hello from my AI agent',
text: 'This email was sent by an AI agent using AgenticMail.',
});
// Check inbox
const inbox = await client.listInbox(10);
for (const msg of inbox) {
console.log(`${msg.from} — ${msg.subject}`);
}
// Read a specific email
const email = await client.readMessage(inbox[0].uid);
console.log(email.text);
agenticmail> /send
To: [email protected]
Subject: Test email
Body: Hello from the AgenticMail shell!
Email sent! Message ID: <abc123@localhost>
curl -X POST http://127.0.0.1:3100/api/agenticmail/mail/send \
-H "Authorization: Bearer ak_your_agent_key" \
-H "Content-Type: application/json" \
-d '{
"to": "[email protected]",
"subject": "Hello",
"text": "Sent via the AgenticMail API."
}'
AgenticMail includes a full CLI for managing your server. All commands are available via agenticmail <command> or npx @agenticmail/cli@latest <command>.
| Command | Description |
|---|---|
agenticmail |
Start the server (runs setup first if not initialized). Opens the interactive shell after startup. This is the default command — just run agenticmail with no arguments. |
agenticmail setup |
Run the setup wizard. Walks you through system checks, account creation, service startup, email connection (Gmail/Outlook/custom domain), phone number setup, and OpenClaw integration. Safe to re-run — won't overwrite existing config. |
agenticmail start |
Start the server and open the interactive shell. Ensures Docker is running, Stalwart is up, and the API server is reachable. Automatically installs the auto-start service if not already set up. |
agenticmail stop |
Stop the server. Kills the background API server process. If auto-start is enabled, it will restart on next boot. Use agenticmail service uninstall to fully disable. |
agenticmail status |
Show what's running. Displays the status of Docker, Stalwart, the API server, email connection, and auto-start service. |
| Command | Description |
|---|---|
agenticmail openclaw |
Set up AgenticMail for OpenClaw. Starts infrastructure, creates an agent, configures the OpenClaw plugin, enables agent auto-spawn via hooks, and restarts the OpenClaw gateway. |
AgenticMail installs a system service so it automatically starts when your computer boots. On macOS this is a LaunchAgent; on Linux it's a systemd user service.
| Command | Description |
|---|---|
agenticmail service |
Show auto-start status. Displays whether the service is installed and running. |
agenticmail service install |
Install the auto-start service. AgenticMail will start automatically on boot. The startup script waits up to 10 minutes for Docker to be ready, then checks that Stalwart is running (starts it if needed), then launches the API server. |
agenticmail service uninstall |
Remove the auto-start service. AgenticMail will no longer start on boot. |
agenticmail service reinstall |
Reinstall the service. Use this after config changes or updates to refresh the service file. |
What happens on reboot:
restart: unless-stopped in Docker)If the API server crashes, the system service automatically restarts it.
| Command | Description |
|---|---|
agenticmail update |
Update to the latest version. Checks npm for a new version, updates the CLI and OpenClaw plugin, and restarts the OpenClaw gateway if applicable. |
agenticmail help |
Show available commands. |
Server logs are stored in ~/.agenticmail/logs/:
server.log — API server stdoutserver.err.log — API server stderrstartup.log — Boot sequence log (Docker wait times, Stalwart checks)AgenticMail supports two modes for sending/receiving real internet email:
Use your existing Gmail or Outlook account as a relay. No domain purchase needed. Setup takes under 2 minutes.
How it works:
[email protected][email protected] and delivers them to the agent's local mailbox+ sub-addressing routes replies back to the right agentSetup:
# In the interactive shell:
agenticmail> /relay
# Or via API:
curl -X POST http://127.0.0.1:3100/api/agenticmail/gateway/relay \
-H "Authorization: Bearer mk_your_master_key" \
-H "Content-Type: application/json" \
-d '{
"provider": "gmail",
"email": "[email protected]",
"password": "xxxx xxxx xxxx xxxx"
}'
Requirements:
Full custom domain with Cloudflare. Agents send from [email protected] with proper email authentication.
What gets configured automatically:
v=spf1 include:_spf.mx.cloudflare.net ~all)v=DMARC1; p=quarantine)@domain email aliases for all existing agentsSetup:
curl -X POST http://127.0.0.1:3100/api/agenticmail/gateway/domain \
-H "Authorization: Bearer mk_your_master_key" \
-H "Content-Type: application/json" \
-d '{
"cloudflareToken": "your_cf_api_token",
"cloudflareAccountId": "your_cf_account_id",
"domain": "yourdomain.com",
"gmailRelay": {
"email": "[email protected]",
"appPassword": "xxxx xxxx xxxx xxxx"
}
}'
Cloudflare API token permissions needed:
This is a TypeScript monorepo with 5 packages:
| Package | Description | Install |
|---|---|---|
| @agenticmail/cli | CLI, setup wizard, interactive shell. Install this to get started. | npm i -g @agenticmail/cli |
| @agenticmail/core | Core SDK — accounts, SMTP/IMAP, gateway, spam filter, outbound guard, storage | npm i @agenticmail/core |
| @agenticmail/api | Express REST API server with 75+ endpoints | npm i @agenticmail/api |
| @agenticmail/mcp | MCP server with 62 tools for any MCP-compatible AI client | npm i -g @agenticmail/mcp |
| @agenticmail/openclaw | OpenClaw plugin with 63 tools and skill definition | openclaw plugin install agenticmail |
Dependency graph:
@agenticmail/cli ──────> @agenticmail/api ──> @agenticmail/core
@agenticmail/mcp (standalone — HTTP calls to API)
@agenticmail/openclaw (standalone — HTTP calls to API)
All endpoints are under /api/agenticmail. Authentication via Authorization: Bearer <key> header.
Two key types:
mk_...) — full admin access (create/delete agents, approve blocked emails, gateway config)ak_...) — scoped to one agent (read own inbox, send email, manage own drafts/contacts/etc.)| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/mail/send |
Agent | Send email (text, HTML, attachments) |
GET |
/mail/inbox |
Agent | List inbox messages (paginated) |
GET |
/mail/digest |
Agent | Inbox with body previews |
GET |
/mail/messages/:uid |
Agent | Read full email with headers and attachments |
POST |
/mail/search |
Agent | Search by from, subject, body, date |
POST |
/mail/messages/:uid/move |
Agent | Move to folder |
POST |
/mail/messages/:uid/spam |
Agent | Report as spam |
GET |
/mail/folders |
Agent | List all folders |
GET |
/mail/pending |
Both | List blocked outbound emails |
POST |
/mail/pending/:id/approve |
Master | Approve blocked email |
POST |
/mail/pending/:id/reject |
Master | Reject blocked email |
| Accounts | |||
POST |
/accounts |
Master | Create new agent |
GET |
/accounts |
Master | List all agents with metadata |
GET |
/accounts/me |
Agent | Get own agent info |
DELETE |
/accounts/:id |
Master | Delete agent (with email archival) |
GET |
/accounts/directory |
Both | Agent discovery directory |
| Events | |||
GET |
/events |
Agent | SSE stream — new email with route metadata, flags, expunge events |
| Gateway | |||
GET |
/gateway/status |
Both | Current gateway mode and health |
POST |
/gateway/relay |
Master | Configure relay mode |
POST |
/gateway/domain |
Master | Configure domain mode |
POST |
/gateway/test |
Both | Send a test email |
| Tasks | |||
POST |
/tasks/assign |
Both | Assign task to another agent |
POST |
/tasks/rpc |
Both | Synchronous agent-to-agent RPC (long-poll) |
GET |
/tasks/pending |
Agent | List tasks assigned to me |
POST |
/tasks/:id/claim |
Agent | Claim a pending task |
POST |
/tasks/:id/result |
Agent | Submit task result |
Plus endpoints for drafts, contacts, tags, rules, signatures, templates, scheduled emails, spam management, batch operations, domains, and agent deletion/cleanup.
See the API package README for complete endpoint documentation.
The MCP server exposes 62 tools to any MCP-compatible AI client via stdio transport.
Add to your MCP client configuration (e.g., .mcp.json or project settings):
{
"mcpServers": {
"agenticmail": {
"command": "npx",
"args": ["agenticmail-mcp"],
"env": {
"AGENTICMAIL_API_URL": "http://127.0.0.1:3100",
"AGENTICMAIL_API_KEY": "ak_your_agent_key"
}
}
}
}
For desktop AI applications, add the same configuration to your app's MCP config file (check your app's documentation for the file location).
Once connected, your AI can:
list_inboxsend_emailreply_emailsearch_emailsmanage_draftscheck_taskscall_agentSee the MCP package README for the full tool list.
Already have OpenClaw? Two steps:
# Step 1 — Install AgenticMail globally and run the setup wizard
npm install -g @agenticmail/cli && agenticmail setup
# Step 2 — Connect AgenticMail to your OpenClaw instance
agenticmail openclaw
That's it. The global install gives you the agenticmail command. The openclaw command will start the mail server, create an agent, and merge the plugin config into your openclaw.json automatically. Your OpenClaw agent now has its own email address.
If you prefer to configure manually, add to ~/.openclaw/openclaw.json:
{
"plugins": {
"agenticmail": {
"enabled": true,
"config": {
"apiUrl": "http://127.0.0.1:3100",
"apiKey": "ak_your_agent_key",
"masterKey": "mk_your_master_key"
}
}
}
}
The plugin survives OpenClaw updates — plugin configuration lives in user config (~/.openclaw/openclaw.json), not in the OpenClaw source directory.
Use /chat in the AgenticMail shell to talk directly to your OpenClaw agent in real-time:
╭───────────────────────────────────────────────╮
│ ❯ what's the weather in NYC? │
╰───────────────────────────────────────────────╯
You 👤
╭──────────────╮
│ what's the │
│ weather in │
│ NYC? │
╰──────────────╯
🎀 Fola
╭──────────────────────────────────────╮
│ Currently 42°F and cloudy in NYC. │
╰──────────────────────────────────────╯
\ + Enter for new lines)The call_agent tool intelligently spawns sub-agents:
call_agent(async=true) for long-running tasks. The caller polls /tasks/assigned for completion; the assigned agent emails the result back to the caller when it has email capability enabled. In a localhost-only / no-relay setup the result still lands in the caller's local mailbox, so check /mail/inbox if you don't see an SMTP delivery.See the OpenClaw package README for the full tool list.
The CLI includes a full-featured interactive shell with 44 commands:
agenticmail> /inbox
★ 1 [email protected] Project Update 2m ago
2 [email protected] Re: Budget Review 1h ago
3 [email protected] [repo] New issue #42 3h ago
─────────────────────────────────────────────────
Page 1/3 ─ [←] prev [→] next [v] toggle previews [Esc] back
Use ↑↓ arrow keys to select, Enter to read inline
Key features:
v)Enter)★)←/→ navigationEmail: /inbox /send /read /reply /forward /search /delete /save
/thread /unread /archive /trash
Organize: /folders /contacts /drafts /signature /templates /schedule /tag
Agents: /agents /switch /deleteagent /deletions
Security: /spam /rules /pending
Gateway: /relay /digest /setup /status /openclaw
System: /help /clear /exit
Every outgoing email is scanned before sending. The guard detects:
| Category | Examples |
|---|---|
| API keys | sk-..., AKIA..., ghp_..., sk_live_... |
| Credentials | password: ..., secret: ..., token: ... |
| Private keys | -----BEGIN RSA PRIVATE KEY----- |
| PII | Social security numbers, credit card patterns |
| Internal data | Localhost URLs, internal IPs, config file contents |
When sensitive data is detected:
pending_outbound tablePOST /mail/pending/:id/approve or /reject) or by replying to the notification emailInbound emails are scored against rule-based patterns:
| Category | Score Range | Examples |
|---|---|---|
| Phishing | 10-30 | Fake login pages, urgency language, spoofed senders |
| Scam | 15-25 | Nigerian prince, lottery winner, inheritance schemes |
| Malware | 20-30 | Suspicious attachments, executable links |
| Commercial | 5-15 | Unsolicited marketing, unsubscribe-heavy emails |
| Social engineering | 10-20 | Impersonation, authority pressure |
@localhost from, external replyTo) are always treated as external# === Required ===
AGENTICMAIL_MASTER_KEY=mk_your_key # Master API key (generate: openssl rand -hex 32)
# === Stalwart Mail Server ===
STALWART_ADMIN_USER=admin # Stalwart admin username
STALWART_ADMIN_PASSWORD=changeme # Stalwart admin password
STALWART_URL=http://localhost:8080 # Stalwart HTTP admin URL
# === SMTP/IMAP (local Stalwart) ===
SMTP_HOST=localhost # SMTP host
SMTP_PORT=587 # SMTP submission port
IMAP_HOST=localhost # IMAP host
IMAP_PORT=143 # IMAP port
# === Optional ===
AGENTICMAIL_API_PORT=3100 # API server port (default: 3100)
AGENTICMAIL_DATA_DIR=~/.agenticmail # Data directory for SQLite DB and config
# === Gateway: Relay Mode ===
RELAY_PROVIDER=gmail # gmail or outlook
[email protected] # Your email address
RELAY_PASSWORD=xxxx xxxx xxxx xxxx # App password
# === Gateway: Domain Mode ===
CLOUDFLARE_API_TOKEN=your_token # Cloudflare API token
CLOUDFLARE_ACCOUNT_ID=your_account_id # Cloudflare account ID
AGENTICMAIL_DOMAIN=yourdomain.com # Your domain
AGENTICMAIL_INBOUND_SECRET=your_secret # Shared secret for Email Worker
# === Gmail SMTP Relay (domain mode outbound) ===
[email protected] # Gmail address for outbound relay
GMAIL_RELAY_APP_PASSWORD=xxxx xxxx xxxx # Gmail app password
# === Debug ===
# AGENTICMAIL_DEBUG=1 # Enable verbose per-message logging
# docker-compose.yml (included in repo)
services:
stalwart:
image: stalwartlabs/stalwart:latest
container_name: agenticmail-stalwart
ports:
- "8080:8080" # HTTP Admin + JMAP
- "587:587" # SMTP Submission
- "143:143" # IMAP
- "25:25" # SMTP Inbound
volumes:
- stalwart-data:/opt/stalwart
- ~/.agenticmail/stalwart.toml:/opt/stalwart/etc/stalwart.toml:ro
restart: unless-stopped
AgenticMail stores all state in a SQLite database at ~/.agenticmail/agenticmail.db:
agents — agent accounts (name, email, API key, metadata)gateway_config — relay or domain mode configurationpending_outbound — blocked emails awaiting approvaldelivered_messages — deduplication tracking for inbound relayspam_log — spam scoring historyagent_tasks — inter-agent task assignmentsemail_rules — per-agent email filtering rulescontacts, drafts, signatures, templates, scheduled_emails, tagsgit clone https://github.com/agenticmail/agenticmail.git
cd agenticmail
npm install
docker compose up -d
npm run build
npm test
agenticmail/
├── agenticmail/ # CLI facade package (npm: agenticmail)
│ └── src/
│ ├── cli.ts # CLI entry point (setup, start, status)
│ ├── shell.ts # Interactive REPL (44 commands)
│ └── index.ts # Re-exports from @agenticmail/core
├── packages/
│ ├── core/ # @agenticmail/core
│ │ └── src/
│ │ ├── accounts/ # Agent CRUD, roles, deletion
│ │ ├── mail/ # Sender, receiver, parser, spam filter, outbound guard
│ │ ├── inbox/ # IMAP IDLE watcher
│ │ ├── gateway/ # Relay, Cloudflare, DNS, tunnel, domain purchase
│ │ ├── stalwart/ # Stalwart admin API client
│ │ ├── storage/ # SQLite database, migrations, search index
│ │ ├── domain/ # Domain management
│ │ └── setup/ # Dependency checker, installer
│ ├── api/ # @agenticmail/api
│ │ └── src/
│ │ ├── app.ts # Express app factory
│ │ ├── routes/ # 8 route modules (mail, accounts, events, etc.)
│ │ └── middleware/ # Auth, rate limiting, error handling
│ ├── mcp/ # @agenticmail/mcp
│ │ └── src/
│ │ ├── index.ts # MCP server entry (stdio transport)
│ │ ├── tools.ts # 63 tool definitions and handlers
│ │ └── resources.ts
│ └── openclaw/ # @agenticmail/openclaw
│ ├── index.ts # Plugin entry, system prompt
│ ├── src/tools.ts # 63 tool definitions and handlers
│ └── skill/ # SKILL.md, reference docs, scripts
├── docker-compose.yml # Stalwart mail server
├── .env.example # Environment variable template
└── package.json # Workspace root
# Build all packages
npm run build
# Build a single package
cd packages/core && npx tsup src/index.ts --format esm --dts --clean
# Run all tests
npm test
# Run tests for a specific package
cd packages/core && npx vitest run
Publish in dependency order:
cd packages/core && npm publish
cd packages/api && npm publish
cd packages/mcp && npm publish
cd packages/openclaw && npm publish
cd agenticmail && npm publish
All scoped packages have "publishConfig": { "access": "public" } configured.
See CONTRIBUTING.md for development guidelines.
AgenticMail collects anonymous usage statistics to help improve the product. We track:
We never collect API keys, email content, addresses, or any personal information.
Opt out by setting the environment variable:
export AGENTICMAIL_TELEMETRY=0
# or
export DO_NOT_TRACK=1
Telemetry is also automatically disabled in CI environments.
plugin id mismatch (manifest uses "agenticmail", entry hints "openclaw")
This is harmless. OpenClaw infers the plugin ID from the npm package name (@agenticmail/openclaw) but the manifest declares "id": "agenticmail". The plugin loads and works correctly.
If OpenClaw reports the plugin path not found, update plugins.load.paths in ~/.openclaw/openclaw.json to point to the correct location:
npm prefix -g
# Plugin is at: <prefix>/lib/node_modules/@agenticmail/openclaw
agenticmail: command not foundUse npx agenticmail for one-off usage, or install globally with npm install -g @agenticmail/cli.
MIT - Ope Olatunji (@ope-olatunji)
Add this to claude_desktop_config.json and restart Claude Desktop.
{
"mcpServers": {
"agenticmail": {
"command": "npx",
"args": []
}
}
}