Skill

Send transactional and bulk emails via Mailtrap API or SMTP

Send live email via Mailtrap's Email API or SMTP, choosing correctly between Transactional and Bulk streams and batch requests.

Works with mailtrap

Maintainer of this project? Claim this page to edit the listing.


78
Spark score
out of 100
Updated 26 days ago
Version 13.6.1

Add to Favorites

Why it matters

Configure and troubleshoot live email delivery through Mailtrap's Email API or SMTP, routing transactional (app-generated) and bulk (promotional) messages with batch support for high-volume sends.

Outcomes

What it gets done

01

Route transactional emails (password resets, receipts, alerts) through Mailtrap's send API with proper authentication

02

Configure bulk promotional email streams with correct endpoints and rate-limit handling

03

Submit batch requests of up to 500 messages in a single API call to reduce HTTP overhead

04

Debug SMTP integration issues by validating host, port, and token configuration for legacy systems

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-mailtrap-sending-emails | bash

Overview

Sending emails (Mailtrap)

Covers live email sending via Mailtrap's Email API and SMTP, choosing correctly between the Transactional and Bulk streams and the batch request mechanism. Use when integrating or troubleshooting live Mailtrap sending, choosing between transactional/bulk streams, API/SMTP, and batch requests.

What it does

This skill covers sending live email through Mailtrap's Email API (REST) or SMTP, across two distinct streams - Transactional (non-promotional, app-generated: password resets, receipts, alerts) and Bulk (promotional/marketing volume) - plus Batch, which is not a third stream but a way to submit up to 500 different messages in one request on whichever stream matches the content. Campaigns is a separate product path entirely, for promotional mail sent to recipients stored as Mailtrap contacts with built-in audience management, scheduling, and reporting.

When to use - and when NOT to

Use it when integrating, configuring, or troubleshooting live sending via Email API, SMTP, transactional or bulk streams, or batch requests. It explicitly is not the right skill for sandbox-only testing (that's mailtrap-testing-with-sandbox), step-by-step Campaigns UI setup, webhook configuration, or deliverability deep-dives, and it defers to Mailtrap's own docs for exhaustive schemas once the integration path is clear. Integration method follows a strict preference order: a platform-specific plugin or no-code integration first, then an official SDK (Node.js, Python, PHP, Ruby, Java, .NET, CLI), then the raw HTTP Email API, and SMTP only as a last resort for legacy stacks that can't speak HTTP.

Inputs and outputs

Transactional sends go to POST https://send.api.mailtrap.io/api/send (batch: /api/batch); Bulk sends use the identical JSON shape but a different host, POST https://bulk.api.mailtrap.io/api/send - the same $MAILTRAP_API_TOKEN works on both hosts as long as its scope covers that stream. SMTP mirrors this split: live.smtp.mailtrap.io for transactional, bulk.smtp.mailtrap.io for bulk, both on port 587 (or 25/2525/465-SSL) with username api and the API token as password. A typical JSON body has from, to, subject, and text/html, or template_uuid/template_variables to use a Mailtrap-hosted template instead of raw content. The sending API is rate-limited to 150 requests per 10 seconds per token, requiring backoff on 429. Mailtrap automatically manages suppressions - hard bounces, spam reports, unsubscribes - and will not resend to those addresses.

curl -X POST https://bulk.api.mailtrap.io/api/send \
  -H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
  -d '{"from":{"email":"hello@yourdomain.com"},"to":[{"email":"user@example.com"}],"subject":"Promotional","html":"<p>Hi</p>"}'

Integrations

Official SDKs exist for Node.js, Python, PHP, Ruby, Java, .NET, and a CLI - the skill insists on reading each SDK's README before generating code rather than guessing method signatures from memory. It pairs with mailtrap-setting-up-sending-domain (domain verification required before sends flow) and mailtrap-testing-with-sandbox for safe pre-production testing.

Who it's for

Developers integrating live email sending into an application who need to pick the right stream (transactional vs. bulk), the right transport (API vs. SMTP), and avoid the most common mistake the skill names explicitly: confusing batch (many messages, one request) with bulk (the promotional stream and host) and sending promotional traffic to the transactional host by accident.

Source README

Sending emails (Mailtrap)

Overview

Mailtrap sends live email over Email API (REST) or SMTP. Two streams apply for API/SMTP: Transactional (non-promotional, app-generated) and Bulk (promotional / marketing volume). Batch is not a third stream: it is how you submit many messages in one request on whichever stream matches the content. Campaigns are a separate product path for promotional mail to Mailtrap contacts. Pair this sheet with the Transactional / Bulk developer pages when building or debugging integrations (including with AI-assisted coding).

When to Use

Use when integrating, configuring, or troubleshooting Mailtrap live email sending with Email API, SMTP, transactional streams, bulk streams, or batch requests.

How to integrate (preference order)

Preferred order:

  1. Plugin or integration for the user's platform (no-code or minimal-config) where available
  2. Official SDK for your language when one exists (maintained clients, typed helpers, less room for URL/auth mistakes).
  3. HTTP Email API when there is no SDK or the SDK does not fit (direct POST to /api/send or /api/batch with JSON).
  4. SMTP only when you really need it (legacy stack, host/platform that only speaks SMTP, or hard constraints that rule out HTTP).

Choosing how to send

Approach Use when
Transactional, single message Email generated by your app (password resets, receipts, notifications, alerts). One logical message per POST https://send.api.mailtrap.io/api/send
Bulk Promotional email to contacts that you manage on your side and send at volume through Mailtrap. Not the same as "batch": bulk is the stream, not the batch endpoint.
Batch You have multiple different messages to hand off at the same time (up to 500 per request). Cuts HTTP overhead; can be applied to both transactional and bulk
Campaigns Promotional email to recipients stored as Mailtrap contacts, using Mailtrap Campaigns (audiences, scheduling, reporting in the product). Recommended to avoid implementing contact management and email sending logic; requires UI setup before sends flow-this skill does not replace that workflow.

Before generating SDK code: read the README of the relevant SDK repository linked in the SDKs section below for current method signatures, constructor options, and examples. Do not rely on memory.

Related skills: mailtrap-testing-with-sandbox (safe testing) and mailtrap-setting-up-sending-domain (verification before send).

When not to use

  • Sandbox only-capturing mail without delivery, reading messages in a sandbox (mailtrap-testing-with-sandbox).
  • The main ask is webhooks, step-by-step Campaigns UI setup, or deliverability deep-dives.
  • Exhaustive API reference-once the user's path is clear, link the official send docs for full schemas, optional fields, and edge cases.

Quick reference

Email API

Stream Send Endpoint Batch Endpoint Authorization Header
Transactional POST https://send.api.mailtrap.io/api/send POST https://send.api.mailtrap.io/api/batch Authorization: Bearer $MAILTRAP_API_TOKEN
Bulk (promotional / marketing volume) POST https://bulk.api.mailtrap.io/api/send POST https://bulk.api.mailtrap.io/api/batch Authorization: Bearer $MAILTRAP_API_TOKEN

SMTP

Setting Transactional Bulk
Host live.smtp.mailtrap.io bulk.smtp.mailtrap.io
Port 587 (also 25, 2525, 465 with SSL) 587 (also 25, 2525, 465 with SSL)
Username api api
Password API token ($MAILTRAP_API_TOKEN) API token ($MAILTRAP_API_TOKEN)

Tokens

Use $MAILTRAP_API_TOKEN in either Authorization: Bearer ... or Api-Token: .... The same token works on both send.api.mailtrap.io and bulk.api.mailtrap.io as long as its scope covers the stream. Store tokens in environment variables or a secrets manager and rotate them when access changes.

Rate limits

Scope Limit Window
Sending API (per token) 150 requests 10 seconds

Use backoff on 429.

JSON body (non-template)

Typical fields include from, to, subject, and text and/or html. Optional: category, custom_variables. Exact request bodies: Transactional send and Bulk send.

Examples (curl)

Transactional send (send.api.mailtrap.io):

curl -X POST https://send.api.mailtrap.io/api/send \
  -H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {"email": "hello@yourdomain.com", "name": "Your App"},
    "to": [{"email": "user@example.com"}],
    "subject": "Hello",
    "text": "Plain text body"
  }'

Bulk stream uses the same path and JSON shape on the bulk host (same env var; the token only needs bulk-stream scope):

curl -X POST https://bulk.api.mailtrap.io/api/send \
  -H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {"email": "hello@yourdomain.com", "name": "Your App"},
    "to": [{"email": "user@example.com"}],
    "subject": "Promotional",
    "html": "<p>HTML body</p>"
  }'

Batch (array of messages; up to 500 per request - see API docs for full schema):

curl -X POST https://send.api.mailtrap.io/api/batch \
  -H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"from":{"email":"a@example.com"},"to":[{"email":"b@example.com"}],"subject":"One","text":"..."}]}'

JSON body (template)

Use template_uuid and template_variables instead of raw text/html to use a template hosted by Mailtrap. Minimal example:

curl -X POST https://send.api.mailtrap.io/api/send \
  -H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {"email": "hello@yourdomain.com", "name": "Your App"},
    "to": [{"email": "user@example.com"}],
    "template_uuid": "your-template-uuid",
    "template_variables": {"user_name": "Jane"}
  }'

Use the same API operations as non-template sends.

SDKs

Suppressions

Mailtrap automatically manages suppressions for addresses that hard bounce, report spam, or unsubscribe, and will not send emails to these suppressed recipients again. For details, see the Suppressions documentation.

Common mistakes

Mistake Fix
Confusing batch with bulk Batch = many messages in one /api/batch request. Bulk = promotional stream/host and token
Promotional API mail on transactional host Use bulk base URL and bulk token for promotional content you generate in code
Bulk traffic on send.api.mailtrap.io Promotional/bulk stream uses bulk.api.mailtrap.io
Using sandbox SMTP host for live sending Live sending uses live.smtp.mailtrap.io or bulk.smtp.mailtrap.io
SMTP username is an email address Username is api; password is the API token
Sending before domain is verified Complete Sending Domains setup and compliance (see mailtrap-setting-up-sending-domain)
Guessing SDK API from memory Read the SDK README and OpenAPI-linked examples; do not invent constructors or method names
Choosing SMTP first for a greenfield app Prefer platform integration if one exists, then SDK, then HTTP API; SMTP only when necessary (see How to integrate)

Limitations

  • This skill summarizes Mailtrap sending choices; use Mailtrap's current API docs for exhaustive schemas and product limits.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.