Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
.claude/skills/affaan-m-mailtrap-email-integration/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 8% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 102% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-08 | ✓→✓ | = Same ✓ | 22% | 0% |
| case-22 | ✓→✓ | = Same ✓ | 7% | 0% |
Patterns for adding transactional email sending to an application using Mailtrap's Email API and Sandbox, covering authentication, environment separation, and common delivery pitfalls.
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.
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: "no-reply@yourverifieddomain.com", 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-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 |
api-and-interface-design, security-and-hardening, ci-cd-and-automation
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | pass→pass | 20,143 | 20,301 | +1% | 1 | 1 | 0% | 4,312 | 5,248 | +22% | 0 | 0 | — |
case-01 | fail→fail | 16,907 | 8,847 | -48% | 1 | 1 | 0% | 3,439 | 2,630 | -24% | 0 | 0 | — |
case-02 | fail→pass | 10,832 | 8,338 | -23% | 1 | 1 | 0% | 2,289 | 2,479 | +8% | 0 | 0 | — |
case-03 | fail→fail | 10,093 | 10,274 | +2% | 1 | 1 | 0% | 2,216 | 3,178 | +43% | 0 | 0 | — |
case-22 | pass→pass | 13,210 | 9,860 | -25% | 1 | 1 | 0% | 2,304 | 2,461 | +7% | 0 | 0 | — |
case-04 | pass→pass | 8,400 | 4,816 | -43% | 1 | 1 | 0% | 1,529 | 1,671 | +9% | 0 | 0 | — |
case-05 | fail→pass | 9,438 | 7,667 | -19% | 1 | 1 | 0% | 1,207 | 2,436 | +102% | 0 | 0 | — |
case-06 | pass→pass | 3,025 | 3,038 | +0% | 1 | 1 | 0% | 546 | 1,349 | +147% | 0 | 0 | — |
case-07 | pass→pass | 8,764 | 6,278 | -28% | 1 | 1 | 0% | 1,849 | 2,130 | +15% | 0 | 0 | — |
case-09 | pass→pass | 9,865 | 8,094 | -18% | 1 | 1 | 0% | 2,029 | 2,351 | +16% | 0 | 0 | — |
case-10 | pass→pass | 6,548 | 6,910 | +6% | 1 | 1 | 0% | 1,217 | 1,728 | +42% | 0 | 0 | — |
case-11 | pass→pass | 6,726 | 5,002 | -26% | 1 | 1 | 0% | 1,495 | 1,800 | +20% | 0 | 0 | — |
case-12 | pass→pass | 6,552 | 3,426 | -48% | 1 | 1 | 0% | 1,341 | 1,458 | +9% | 0 | 0 | — |
case-13 | pass→pass | 15,050 | 10,044 | -33% | 1 | 1 | 0% | 2,723 | 2,654 | -3% | 0 | 0 | — |
case-14 | pass→pass | 14,104 | 13,121 | -7% | 1 | 1 | 0% | 2,379 | 3,292 | +38% | 0 | 0 | — |
case-15 | pass→pass | 13,602 | 10,222 | -25% | 1 | 1 | 0% | 2,369 | 2,773 | +17% | 0 | 0 | — |
case-16 | pass→pass | 9,234 | 5,531 | -40% | 1 | 1 | 0% | 1,986 | 2,087 | +5% | 0 | 0 | — |
case-17 | pass→pass | 13,252 | 8,756 | -34% | 1 | 1 | 0% | 2,348 | 2,316 | -1% | 0 | 0 | — |
case-18 | fail→pass | 23,618 | 15,453 | -35% | 1 | 1 | 0% | 1,647 | 1,946 | +18% | 0 | 0 | — |
case-19 | pass→pass | 7,596 | 18,085 | +138% | 1 | 1 | 0% | 1,338 | 1,821 | +36% | 0 | 0 | — |
case-20 | pass→pass | 3,065 | 2,565 | -16% | 1 | 1 | 0% | 552 | 1,240 | +125% | 0 | 0 | — |
case-21 | pass→pass | 11,918 | 7,865 | -34% | 1 | 1 | 0% | 2,418 | 2,303 | -5% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 8/3/2026 | +5% |
Other measured skills in the registry, with their headline benchmark lift.