Test every email your AI agent generates
Route every email your AI workflow generates to a safe sandbox where you can inspect and validate before it reaches a real inbox. Catch bad replies, hallucinations, and formatting issues before they go live. Flip to live sending with one config change.
Every endpoint your agent needs for email workflows
Create sandboxes, capture every email your AI sends, and validate agent-generated content – sender, recipients, body, headers, attachments, spam score – from a single API.
curl -X POST https://mailtrap.io/api/projects/{project_id}/sandboxes \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"sandbox": {
"name": "My Test Sandbox"
}
}'
Everything you need to test agent email
-
Isolated sandboxes
Create a sandbox for every agent, environment, or test run.
-
Safe email capture
Every message is captured for inspection instead of being delivered.
-
Full message access
Access captured messages, headers, HTML, attachments, and raw source via API.
-
Spam score & HTML/CSS analysis
Validate deliverability and rendering, before emails reach production
-
Built for automated testing
Create, send, inspect, and clean up sandboxes programmatically.
-
MCP server
Test email from Claude, Cursor, VS Code, and other AI tools.
-
Email address with + variations
Create unlimited test scenarios using tagged email addresses like ‘agent+signup@…’ or ‘agent+billing@…’ without creating new sandboxes.
-
Share messages with your team
Collaborate on email reviews by sharing captured messages across engineering, QA, and product teams.
Test email directly from Claude, Cursor, and VS Code
Expose Mailtrap Sandbox as MCP tools so agents can send test emails, inspect results, and validate output without writing API code.
{
"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"
}
}
}
}
Why test your agent's emails
AI agents don't produce the same output every time. A sandbox lets you review what they can actually generate before a real recipient sees it.
-
Catch agent mistakes before they ship
Review every email your agent generates before it reaches a real recipient.- Catch hallucinated content and wrong recipients
- Review the full message before delivery
- Compare output against expected behavior
-
Verify what your workflow sends
Whether your AI runs in Zapier, n8n, custom code, or anywhere else, route the email it generates to Sandbox first and check what came out.- Inspect every email before your workflow moves on
- Check spam score, HTML, and content automatically
- Detect regressions after prompt or model changes
-
Add human approval when needed
When your logic determines a message needs human review, preview it in Sandbox first. Once approved, switch to live sending.- Review drafts before sending
- Flip from sandbox to live
- Keep autonomous workflows under control
Built for teams testing AI-generated email
Whether you're building agents, internal applications, or automation workflows, Agent Email Sandbox helps you test email safely before it reaches real recipients.
-
AI builders & enthusiasts
Test what your agent would send before it goes live.- Validate agent-generated replies
- Compare outputs across prompts and model versions
- Iterate fast without spamming real inboxes
-
Engineering teams
Add inbound email to internal systems, databases, support tools, and workflows.- Add inbound email to your internal apps and automations
- Save each parsed message to your database after fetching it from the Messages API
- Use a hosted address to get started, then move to your own custom domain for production
-
SMBs & customer-facing businesses
Use email as an event source for automation pipelines, approvals, routing, and notifications.- Kick off pipelines and jobs as soon as an email arrives
- Spin up and tear down disposable sandboxes per workflow, all via API
- Isolate dev, staging, and production on separate sandboxes
Connect with the tools your team already uses
Add sandbox into your stack. Trigger tests from CI, push captured messages to your eval framework, queues, or databases, and reach it over the native connectors, API, or MCP.
-
Supabase
Native Mailtrap SMTP integration for Supabase projects. -
Vercel
Native integration for sending and testing environments. -
Claude Code
Send emails, manage templates & sending domains, and pull stats. -
Mailtrap MCP Server
Send emails, manage templates and pull delivery stats from AI clients. -
Cursor
Send emails and manage email templates directly from Cursor. -
Google Antigravity
Send and test emails and manage templates in Antigravity.
Frequently Asked Questions
-
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.
-
Do test emails ever reach real people?
No. By default, everything your agent sends to a sandbox stays in the sandbox. If you do need to send a specific message to a real address – for example, to share an approved draft — you can forward it to a recipient you’ve confirmed in advance. Otherwise nothing leaves the Email Sandbox.
-
Can my agent drive the sandbox over MCP?
Yes. With the Mailtrap MCP server added to your editor, your agent can send test emails, pull and search captured messages, read their content and headers, and check spam score and HTML — all as natural-language tool calls, without you writing API plumbing.
-
How is this different from the inbound agent inbox?
The agent inbox is about email coming in — your agent receives a message, parses it, and reacts. The sandbox is about email going out. If your agent uses Inbound in production, route its outbound replies to Sandbox during dev — you’ll see exactly what gets sent back before any real recipient does.
-
Can I create a separate sandbox for each agent or test run?
Yes. Organize sandboxes under projects and create or delete them through the API, so each agent, environment, or test run gets its own isolated sandbox. That keeps one agent’s test mail from mixing with another’s, and lets you spin up a fresh sandbox for a run and tear it down the moment it finishes.
-
Can my agent reply to emails from the sandbox?
No. Sandbox is designed for safe email testing and review, not for sending emails to recipients.
To send a real email, use Mailtrap Email Sending API or SMTP. If you’re working with inbound emails, use the Inbound Reply API to respond within the original thread.
The APIs are designed to work together, making it easy to preview an AI-generated email in Sandbox first and then send the approved version through the appropriate sending endpoint.
-
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.