API Reference
Complete API documentation for Mailtrap email infrastructure
Welcome to the Mailtrap API documentation. Our APIs provide comprehensive access to email sending, testing, contact management, and account administration features.
Available APIs
Send transactional and bulk emails with reliable delivery.
Transactional emails
Bulk campaigns
Email templates
Domain management
Test emails safely in isolated environments.
Test inboxes
Email inspection
SMTP testing
API automation
Manage contacts and marketing campaigns.
Contact management
List segmentation
Import/export
Event tracking
Receive real-time event notifications.
Delivery events
Engagement tracking
Bounce handling
Custom processing
Create reusable email designs.
Dynamic content
Variable substitution
Version control
A/B testing
Control users and settings.
User permissions
Billing management
Security settings
Audit logs
Quick Start
Get API Credentials
Sign up for a Mailtrap account
Navigate to API Tokens
Generate a new API token with required permissions
Install SDK
Choose your preferred programming language:
npm install mailtrappip install mailtrapcomposer require railsware/mailtrap-phpgem install mailtrap<dependency>
<groupId>io.mailtrap</groupId>
<artifactId>mailtrap-java</artifactId>
<version>2.0.0</version>
</dependency>The .NET SDK is available via GitHub Packages. First, add the GitHub source:
dotnet nuget add source https://nuget.pkg.github.com/mailtrap/index.json \
--name github-mailtrap \
--username GITHUB_USERNAME \
--password GITHUB_PATThen install the package:
dotnet add package Mailtrap -s github-mailtrapSend First Email
import { MailtrapClient } from "mailtrap";
const mailtrap = new MailtrapClient({
token: process.env.MAILTRAP_API_KEY, // You can create your API key here https://mailtrap.io/api-tokens
});
mailtrap
.send({
from: { name: "Mailtrap Test", email: "[email protected]" },
to: [{ email: "[email protected]" }],
subject: "Hello from Mailtrap Node.js",
text: "Plain text body",
})
.then(console.log)
.catch(console.error);import mailtrap as mt
API_TOKEN = "<YOUR_API_TOKEN>" # your API key here https://mailtrap.io/api-tokens
client = mt.MailtrapClient(token=API_TOKEN)
# Create mail object
mail = mt.Mail(
sender=mt.Address(email="[email protected]", name="John Smith"),
to=[mt.Address(email="[email protected]")],
subject="You are awesome!",
text="Congrats for sending test email with Mailtrap!",
)
client.send(mail)Next Steps
Choose an API to explore:
Getting Started? Begin with the Email API for sending your first email.
Last updated
Was this helpful?

