Guides
AgentMail Integration
Give your agents email addresses via AgentMail
AgentMail Integration
Give your agents email addresses via AgentMail. Emails are routed to agents as tasks or inbox messages.
Setup
- Create an account at AgentMail
- Set up a webhook pointing to your server
Webhook URL: https://your-server.com/api/agentmail/webhook
Configuration
AGENTMAIL_WEBHOOK_SECRET=your-svix-secret
# Optional: filter incoming webhooks by domain
AGENTMAIL_INBOX_DOMAIN_FILTER=yourdomain.com
AGENTMAIL_SENDER_DOMAIN_FILTER=gmail.com,company.comDomain Filtering
You can restrict which emails are processed using domain filters:
AGENTMAIL_INBOX_DOMAIN_FILTER— Only process webhooks for inboxes on the specified domains. Emails to inboxes on other domains are silently dropped.AGENTMAIL_SENDER_DOMAIN_FILTER— Only process emails from senders on the specified domains. Emails from other sender domains are silently dropped.
Both accept comma-separated domain lists and are optional. When not set, all domains are allowed.
How It Works
Email Routing
Agents self-register which inboxes they receive mail from using the register-agentmail-inbox MCP tool.
- Emails to a worker's inbox become tasks
- Emails to a lead's inbox become inbox messages for triage
- Follow-up emails in the same thread are automatically routed to the same agent
Registering an Inbox
register-agentmail-inbox(
action: "register",
inboxId: "inb_xxx",
inboxEmail: "worker@yourdomain.com"
)Managing Inboxes
# List your registered inboxes
register-agentmail-inbox(action: "list")
# Unregister an inbox
register-agentmail-inbox(action: "unregister", inboxId: "inb_xxx")Sending Email
Agents can send emails using AgentMail MCP tools:
send_message— Send a new emailreply_to_message— Reply to an existing threadforward_message— Forward an emaillist_threads— List email threads in an inbox
Related
- Environment Variables — AgentMail configuration (
AGENTMAIL_WEBHOOK_SECRET, domain filters) - Task Lifecycle — How emails become tasks
- Slack Integration — Another external task source