Trusted by teams building with AI

Atlassian is a customer of Mailtrap
Adobe is a customer of Mailtrap
Yelp is a customer of Mailtrap
PayPal is a customer of Mailtrap
Toptal is a customer of Mailtrap
Calendly is a customer of Mailtrap

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.

  • /projects/{project_id}/sandboxes

    Create hosted sandboxes that capture email instead of delivering it.

  • /sandboxes/{sandbox_id}/messages/{message_id}/mail_headers

    Returns all email headers as key-value pairs.

  • /send/{sandbox_id}

    Send a test email to your sandbox.

  • /sandboxes/{sandbox_id}/messages/{message_id}

    Inspect captured messages, attachments, spam score, and HTML analysis.

View All Endpoints

Copy

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"
    }
  }'
View All Endpoints

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.

Copy

{
  "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

    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

    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

    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

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.

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

    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

    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

    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

Common use cases for Agent Email Sandbox

What teams build with agent sandboxes

AI agent quality testing

AI agent quality testing

Inspect every email your agent drafts and catch the bad ones before a customer sees them.

AI workflow integration

AI workflow integration

Drop the sandbox into agent and automation pipelines to validate output end-to-end.

Customer-facing automation (SMB)

Customer-facing automation (SMB)

Put a safety net under the automated emails your business sends to real customers.

Inbound reply testing

Inbound reply testing

Test how your agent replies to inbound emails before those replies ever go out.

Human-in-the-loop

Human-in-the-loop

Require a person to sign off before any agent-generated email leaves the sandbox.

Question icon

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.