# Mailtrap for AI Agents

> Mailtrap provides email infrastructure purpose-built for AI agents and coding assistants: send transactional and bulk emails, test safely in sandbox, manage templates and contacts, and track deliverability — via MCP, REST API, SDKs, or CLI. Full details at [mailtrap.io/for-ai-agents](https://mailtrap.io/for-ai-agents/).

**Prerequisites:** A Mailtrap account and API token are required. [Sign up free](https://mailtrap.io/) — no credit card needed. Create your API token in account settings.

---

## Integration methods

Three ways to connect Mailtrap to an AI agent or coding assistant:

### 1. MCP Server (recommended for AI IDEs and assistants)

Official MCP server that exposes Mailtrap tools directly to any MCP-compatible environment.

**Install:**
- Cursor: one-click "Install in Cursor" button on [github.com/mailtrap/mailtrap-mcp](https://github.com/mailtrap/mailtrap-mcp)
- VS Code: one-click "Install with Node in VS Code" button on [github.com/mailtrap/mailtrap-mcp](https://github.com/mailtrap/mailtrap-mcp)
- Smithery: `npx @smithery/cli install mailtrap`
- Manual: add to your MCP config and run `npx -y mcp-mailtrap`

**Configuration (Claude Desktop / Cursor):**

```json
{
  "mcpServers": {
    "mailtrap": {
      "command": "npx",
      "args": ["-y", "mcp-mailtrap"],
      "env": {
        "MAILTRAP_API_TOKEN": "your_token",
        "MAILTRAP_ACCOUNT_ID": "your_account_id",
        "DEFAULT_FROM_EMAIL": "sender@yourdomain.com",
        "MAILTRAP_TEST_INBOX_ID": "your_inbox_id"
      }
    }
  }
}
```

`MAILTRAP_API_TOKEN` and `MAILTRAP_ACCOUNT_ID` are required. `DEFAULT_FROM_EMAIL` enables dynamic sender selection. `MAILTRAP_TEST_INBOX_ID` enables sandbox testing tools.

**VS Code:** use the one-click button above, or configure manually under `"mcp.servers"` key instead of `"mcpServers"`.

Source: [github.com/mailtrap/mailtrap-mcp](https://github.com/mailtrap/mailtrap-mcp)

### 2. REST API & SDKs

Full programmatic access via REST API or official SDK for your language.

- [Node.js](https://github.com/mailtrap/mailtrap-nodejs) · [Python](https://github.com/mailtrap/mailtrap-python) · [PHP](https://github.com/mailtrap/mailtrap-php) · [Ruby](https://github.com/mailtrap/mailtrap-ruby) · [Java](https://github.com/mailtrap/mailtrap-java) · [.NET](https://github.com/mailtrap/mailtrap-dotnet) · [Elixir](https://github.com/mailtrap/mailtrap-elixir)
- [API reference & authentication](https://docs.mailtrap.io/developers/readme.md)
- [OpenAPI specs](https://docs.mailtrap.io/developers/openapi-specs.md)

### 3. CLI

Terminal-based access for scripting and automation workflows.

**Install:**
```
brew install mailtrap/cli/mailtrap
# or
go install github.com/mailtrap/mailtrap-cli@latest
```

**Common operations:** send transactional emails · check spam scores · retrieve sending stats · bulk import contacts from JSON

Source: [github.com/mailtrap/mailtrap-cli](https://github.com/mailtrap/mailtrap-cli)

---

## What agents can do

Once connected via MCP, API, or CLI, an agent can perform the following:

**Sending**
- Send transactional emails (inline content or template-based)
- Send bulk/marketing emails via a separate bulk stream
- Access email logs with filtering and search

**Testing**
- Send test emails to sandbox inbox (no real delivery)
- Retrieve sandbox messages with full HTML/text content
- Check spam scores before sending

**Templates**
- Create, list, update, and delete email templates
- Use Handlebars syntax for dynamic content (conditionals, loops, variables)

**Analytics**
- Retrieve sending statistics by date range
- Filter by domain, category, or email provider
- View engagement metrics: opens, clicks, bounces, complaints

**Domain management**
- List and create sending domains
- Check DNS verification status and retrieve setup instructions

**Contact management**
- Manage contacts, lists, and segments
- Import contacts in bulk

---

## Mailtrap Skills

Skills are installable context modules for AI coding assistants — they provide Mailtrap API patterns, workflow context, and pointers to official docs, so the assistant can work with Mailtrap without hallucinating endpoints or parameters.

**Install:**
```
npx skills add mailtrap/mailtrap-skills
```

Or copy/symlink skill folders manually:
- Cursor (project): `.cursor/skills/`
- Cursor (global): `~/.cursor/skills/`

**Six included skills:**

| Skill                        | What it covers                                      |
|------------------------------|-----------------------------------------------------|
| sending-emails               | Email API and SMTP sending workflows                |
| testing-with-sandbox         | Capturing and inspecting emails in development      |
| using-email-templates        | Template management and Handlebars syntax           |
| converting-email-templates   | Migrating templates from other platforms            |
| setting-up-sending-domain    | Domain verification and DNS setup                   |
| managing-contacts            | Contact API, lists, and segments                    |

Source: [github.com/mailtrap/mailtrap-skills](https://github.com/mailtrap/mailtrap-skills)

---

## Supported AI platforms

Mailtrap MCP and Skills are compatible with:

Claude Code · Cursor · GitHub Copilot · VS Code · Windsurf · Replit · Lovable · Bolt.new · Retool · V0 · Augment Code · Qodo · OpenCode · Base44 · Reflex Build · Leap.new · and any other MCP-compatible environment.

---

## Resources

- [AI onboarding guide](https://docs.mailtrap.io/getting-started/ai-onboarding.md): step-by-step setup for all integration methods
- [Full docs index](https://docs.mailtrap.io/llms.txt): complete documentation reference
- [Pricing](https://mailtrap.io/pricing.md): all plans and feature tiers
