Email for Agents
Email infrastructure for AI Agents
Give your AI agent a complete email layer. Send emails, receive replies, test output safely, and manage email workflows through a single API and MCP server.
-
cURL
cURL.txt
Copy
// Claude or Cursor
{
"mcpServers": {
"mailtrap": {
"command": "npx",
"args": ["-y", "mcp-mailtrap"],
"env": {
"MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
"DEFAULT_FROM_EMAIL": "your_sender@example.com",
"MAILTRAP_ACCOUNT_ID": "your_account_id",
"MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
}
}
}
}
// VS Code
{
"mcp": {
"servers": {
"mailtrap": {
"command": "npx",
"args": ["-y", "mcp-mailtrap"],
"env": {
"MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
"DEFAULT_FROM_EMAIL": "your_sender@example.com",
"MAILTRAP_ACCOUNT_ID": "your_account_id",
"MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
}
}
}
}
}
// Claude Code (asdf)
{
"mcpServers": {
"mailtrap": {
"command": "/Users/<username>/.asdf/shims/npx",
"args": ["-y", "mcp-mailtrap"],
"env": {
"PATH": "/Users/<username>/.asdf/shims:/usr/bin:/bin",
"ASDF_DIR": "/opt/homebrew/opt/asdf/libexec",
"ASDF_DATA_DIR": "/Users/<username>/.asdf",
"ASDF_NODEJS_VERSION": "20.6.1",
"MAILTRAP_API_TOKEN": "your_mailtrap_api_token",
"DEFAULT_FROM_EMAIL": "your_sender@example.com",
"MAILTRAP_ACCOUNT_ID": "your_account_id",
"MAILTRAP_TEST_INBOX_ID": "your_test_inbox_id"
}
}
}
}
// MCP Bundle (MCPB)
# Build TypeScript and pack the MCPB bundle
npm run mcpb:pack
# Inspect bundle metadata
npm run mcpb:info
# Sign the bundle for distribution (optional)
npm run mcpb:sign
Trusted by teams building with AI
One API for the complete agent email lifecycle
Test outbound email, receive inbound messages, trigger workflows, and send replies — all via Mailtrap API.
-
/inbound/folders/{id}/inboxes
Create dedicated inboxes for agents or AI workflows in seconds.
-
/inbound/inboxes/{id}/messages/{id}/reply
Reply in-thread; Mailtrap handles headers and sender address.
-
/sandboxes/{id}/messages/{id}
Inspect captured messages, spam score, HTML – before any email reaches a recipient.
-
/api/webhooks
Get real-time notifications when emails arrive, so your workflows react instantly without polling.
Copy
curl -X GET https://mailtrap.io/api/inbound/folders/{folder_id}/inboxes \
-H 'Authorization: Bearer YOUR_API_KEY'
Built for teams adding email to AI agents and workflows
Whether you're building Mailtrap provides the complete email layer to manage email via a single API and MCP server.
-
Engineering teams
Add inbound email to your product without running email infrastructure.
- Create inboxes programmatically
- Receive parsed email as structured JSON
- Store messages, attachments, and conversation history
- Trigger application logic from incoming email
-
AI builders & enthusiasts
Give every agent its own inbox and full email context.
- Create inboxes for agents, assistants, and copilots
- Turn incoming email into agent events
- Access complete conversation threads
- Reply in-thread through the API
-
Automation & ops builders
Use email as a trigger for workflows and business processes.
- Start workflows when emails arrive
- Route messages to the right system or team
- Process invoices, approvals, and notifications
- Connect email to n8n, Make, or custom automations
Common use cases for the Inbound Email API
How teams use inbound email with Mailtrap’s API
AI Support Agent
Receive support emails, create tickets, draft replies.
AI Receptionists
Read appointment requests, answer common questions, and schedule meetings.
GitHub Automation
Convert alert emails into issues and tasks.
Invoice Processing
Extract PDFs and trigger accounting workflows.
AI agent quality testing
Inspect every email your agent drafts and catch the bad ones before a customer sees them.
Inbound reply testing
Test how your agent replies to inbound emails before those replies ever go out.
Power up your workflow with smart integrations
Easily connect Mailtrap to the tools you use and keep everything running smoothly.
Supabase
Vercel
Claude Code
Mailtrap MCP Server
Cursor
Google Antigravity
Frequently Asked Questions
-
How do you give an AI agent its own programmable email inbox?
Call the Mailtrap API to create an inbox, then register a webhook URL where your agent gets notified when new mail arrives. Start on a Mailtrap-hosted address with no MX records, no DNS, and no mail server to set up, or connect your own custom domain when you’re ready for production. The moment an email lands, your agent gets a webhook notification and can fetch the fully parsed message from the Messages API. Create or delete inboxes programmatically for each agent, project, or session.
-
Why give an agent a dedicated inbox instead of access to Gmail?
OAuth into a personal Gmail account hands your agent someone’s entire mailbox, with all the privacy, scope, and security questions that it brings, and it breaks the moment a token is revoked. A dedicated agent inbox is isolated, scoped to addresses you control, and provisioned per agent or project. Your agent only ever sees emails meant for it, and you can spin inboxes up or tear them down without touching anyone’s personal account.
-
Do I need a custom domain or DNS setup to receive email?
No, not to get started. A Mailtrap-hosted inbox works the moment you create it, with nothing to add in DNS and no MX records to configure. When you’re ready for production, connect your own custom domain and keep the same API and webhooks. Replies go out the same way in both cases, with a single API call.
-
Can my agent reply to inbound emails?
Yes. Replying is part of the same API, so your agent answers in-thread with a single API call and the conversation flows both ways. On a Mailtrap-hosted inbox, replies are capped at 20 in total; connect your own custom domain and that limit goes away.
-
What is an email sandbox for AI agents?
It’s a safe, Mailtrap-hosted environment that captures the email your AI agent sends instead of delivering it. Your agent sends exactly as it would in production but every message lands in the sandbox, where you can read the content, headers, and attachments, check the spam score, and validate the HTML. Nothing reaches a real recipient, so you can test what an agent generates without any risk of emailing a customer by mistake.
-
How do I add a human-in-the-loop approval step to my AI email workflow?
A common approach is to have your AI agent generate emails in Mailtrap Sandbox first instead of sending them directly.
You can review the message in the Mailtrap UI or retrieve its content, spam score, HTML checks, and other analysis via API. If changes are needed, your AI agent can revise the draft and send an updated version to Sandbox for another review cycle.
Once the email looks right, switch to Mailtrap’s sending endpoint (or the Inbound Reply API for inbound conversations) to deliver the final message. This creates a simple human approval workflow without changing your email generation logic.