Start sending with Mailtrap Email API in minutes
Deliverability-first email API that 150k+ developers trust. 24/7 expert support
-
Node.js
-
Python
Node.js.txt
Copy
import { MailtrapClient } from "mailtrap";
const client = new MailtrapClient({
token: process.env.MAILTRAP_API_KEY,
});
async function sendEmail() {
await client.send({
from: {
email: "sender@example.com",
name: "Sender Name"
},
to: [{ email: "recipient@example.com" }],
subject: "Hello from Mailtrap",
text: "Welcome to Mailtrap!",
html: "<h1>Welcome to Mailtrap!</h1>"
});
}
sendEmail();
Automate emails through MCP
Add the Resend MCP server to your agent and it gets native access to send email, manage contacts, and handle inbound messages.
Copy
import { MailtrapClient } from "mailtrap";
const client = new MailtrapClient({
token: process.env.MAILTRAP_API_KEY,
});
async function sendEmail() {
await client.send({
from: {
email: "sender@example.com",
name: "Sender Name"
},
to: [{ email: "recipient@example.com" }],
subject: "Hello from Mailtrap",
text: "Welcome to Mailtrap!",
html: "<h1>Welcome to Mailtrap!</h1>"
});
}
sendEmail();
Email API with an endpoint for every workflow
RESTful endpoints to send emails, manage templates, and suppressions, track delivery via logs and webhooks — all from a single, well-documented API.
Copy
import { MailtrapClient } from "mailtrap";
const client = new MailtrapClient({
token: process.env.MAILTRAP_API_KEY,
});
async function sendEmail() {
await client.send({
from: {
email: "sender@example.com",
name: "Sender Name"
},
to: [{ email: "recipient@example.com" }],
subject: "Hello from Mailtrap",
text: "Welcome to Mailtrap!",
html: "<h1>Welcome to Mailtrap!</h1>"
});
}
sendEmail();