Skip to main content
Agent skill

Mailtrap Email Integration

Guides agents through integrating transactional email sending via Mailtrap's Email API, including sandbox testing, domain verification, and API authentication. Use when implementing email-sending features, debugging delivery issues, or setting up safe dev/staging email testing.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Mailtrap Email Integration when an AI agent needs a reusable SKILL.md workflow for this job: Guides agents through integrating transactional email sending via Mailtrap's Email API, including sandbox testing, domain verification, and API authentication. Use when implementing email-sending features, debugging delivery issues, or setting up safe dev/staging email testing.

When not to use it

Skip Mailtrap Email Integration when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/mailtrap-email-integration
# Save SKILL.md to ~/.claude/skills/mailtrap-email-integration/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/mailtrap-email-integration/SKILL.md. For a shared project, commit the folder at .claude/skills/mailtrap-email-integration/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Mailtrap Email Integration skill for this task: Use Mailtrap Email Integration when this documented workflow matches the task. Confirm any required inputs or files before making changes.

What supports this recommendation?

75/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
83/100
Practical detail
74/100
Source evidence
63/100
Source signals
72/100
Model compatibility evidence
  • claudeuntested

    No model-specific signal or recorded compatibility test was found.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# Mailtrap Email Integration

Patterns for adding transactional email sending to an application using Mailtrap's Email API and Sandbox, covering authentication, environment separation, and common delivery pitfalls.

## When to Activate

- Implementing a "send email" feature (signup confirmation, password reset, notifications, receipts) - Debugging why emails aren't arriving in dev/staging - Setting up a project's first email-sending integration - Reviewing code that calls an email API directly without sandbox separation

## Core Concepts

**Sandbox vs. Production separation.** Mailtrap provides a Sandbox API that captures emails without delivering them, used for dev/staging so test emails never reach real inboxes. Production sending uses a separate, verified-domain endpoint. Never point a dev environment at the production sending endpoint.

**Authentication.** Requests use a Bearer token in the `Authorization` header. Tokens are scoped per project; sandbox and production typically use different tokens.

**Domain verification.** Production sending requires verifying a sending domain via DNS records (SPF, DKIM, DMARC) before Mailtrap will deliver to real recipients. Skipping this causes silent delivery failures or spam-folder placement.

## Code Examples

```typescript // Sending via Mailtrap's Email API (production) async function sendEmail(to: string, subject: string, html: string) { const response = await fetch("https://send.api.mailtrap.io/api/send", { method: "POST", headers: { "Authorization": `Bearer ${process.env.MAILTRAP_API_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({ from: { email: "[email protected]", name: "Your App" }, to: [{ email: to }], subject, html, }), });

if (!response.ok) { throw new Error(`Email send failed: ${response.status}`); } return response.json(); } ```

```typescript // Same call, routed to Sandbox in non-production environments const MAILTRAP_ENDPOINT = process.env.NODE_ENV === "production" ? "https://send.api.mailtrap.io/api/send" : `https://sandbox.api.mailtrap.io/api/send/${process.env.MAILTRAP_INBOX_ID}`; ```

## Anti-Patterns

| Anti-Pattern | Why It's a Problem | Instead | | --- | --- | --- | | Using the production sending endpoint in dev/test | Real test emails reach real inboxes, risking spam complaints and leaked test data | Route non-production environments to the Sandbox endpoint | | Hardcoding API tokens in source | Credential leak risk if committed to version control | Load tokens from environment variables / secrets manager | | Sending before domain verification completes | Emails silently fail or land in spam | Verify SPF/DKIM/DMARC records before enabling production sending | | No retry/error handling on send failures | Silent notification failures (e.g., user never gets password reset email) | Check response status, log failures, surface actionable errors |

## Best Practices

- Keep sandbox and production tokens in separate environment variables, never share one token across environments - Verify sending domain DNS records before any production launch involving email - Log delivery failures with enough context to debug (recipient, template, timestamp, response code) - Treat email sending as a fallible network call: wrap in try/catch, never assume success

## Related Skills

`api-and-interface-design`, `security-and-hardening`, `ci-cd-and-automation`

Intended uses

  • Use Mailtrap Email Integration when this documented workflow matches the task.

Implementation notes

  • Keep sandbox and production tokens in separate environment variables, never share one token across environments
  • Verify sending domain DNS records before any production launch involving email
  • Log delivery failures with enough context to debug (recipient, template, timestamp, response code)
  • Treat email sending as a fallible network call: wrap in try/catch, never assume success

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.