Overview
Send transactional and bulk emails through Mailtrap's reliable infrastructure
Mailtrap's Email API provides a powerful and reliable way to send transactional and bulk emails through our infrastructure. Whether you're sending order confirmations, password resets, or marketing campaigns, our API has you covered.
Getting Started
Verify Your Sending Domain
Before sending emails, you need to verify ownership of your sending domain:
Go to Sending Domains
Add your domain
Configure DNS records (SPF, DKIM, DMARC)
Verify the records
Emails sent from unverified domains will be rejected.
Get Your API Key
Navigate to API Tokens in your Mailtrap account and generate a new API token with sending permissions.
Install SDK or Use API
Choose an SDK for your programming language or use the API directly with cURL:
No installation required. Use cURL or any HTTP client to make API requests directly.
npm install mailtrap
# or
yarn add mailtrapcomposer require railsware/mailtrap-phppip install mailtrapgem install mailtrapAdd GitHub Packages source to nuget.config:
<packageSources>
<add key="github" value="https://nuget.pkg.github.com/railsware/index.json" />
</packageSources>Then install:
dotnet add package Mailtrap<dependency>
<groupId>io.mailtrap</groupId>
<artifactId>mailtrap-java</artifactId>
<version>2.0.0</version>
</dependency>Send Your First Email
Here's a minimal example to send your first email:
curl -X POST https://send.api.mailtrap.io/api/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": {"email": "[email protected]"},
"to": [{"email": "[email protected]"}],
"subject": "Hello from Mailtrap",
"text": "Welcome to Mailtrap Email API!"
}'import { MailtrapClient } from "mailtrap";
const client = new MailtrapClient({
token: process.env.MAILTRAP_API_KEY
});
await client.send({
from: { email: "[email protected]" },
to: [{ email: "[email protected]" }],
subject: "Hello from Mailtrap",
text: "Welcome to Mailtrap Email API!"
});Email Sending Options
Transactional Emails
Best for real-time, one-to-one emails triggered by user actions:
Order confirmations
Password resets
Account notifications
System alerts
Welcome emails
Endpoint: https://send.api.mailtrap.io/api/send
Bulk Stream
Optimized for high-volume marketing campaigns:
Newsletters
Promotional campaigns
Product announcements
Marketing emails
Endpoint: https://bulk.api.mailtrap.io/api/send
Batch Sending
Send up to 500 emails in a single API call:
Personalized notifications
Event invitations
Account updates
Targeted campaigns
Endpoint: https://send.api.mailtrap.io/api/batch or https://bulk.api.mailtrap.io/api/batch
Limits: 500 messages per call, 50 MB total payload
Features
Email Templates
Create reusable templates with variables for consistent branding and easy updates.
Webhooks
Receive real-time notifications for email events like delivery, bounce, and opens.
Testing with Sandbox
Before going to production, test your email integration with our Sandbox. All official SDKs support Sandbox mode with an easy switch.
We recommend using environment variables to manage the switch between Sandbox and Production modes.
Last updated
Was this helpful?

