Integrations

Nodemailer

Send emails through Mailtrap using Nodemailer in Node.js projects.

How it works

Power up your Nodemailer setup with the official Mailtrap transport. Continue using the familiar Nodemailer syntax you love, but gain access to a full email platform with high-deliverability sending, comprehensive analytics, and a secure sandbox for debugging. It’s the perfect drop-in upgrade for any Node.js project.

Configure

Step 1: Create a Mailtrap account, verify your domain, and get the API token.

Step 2: Install the official package via npm install mailtrap or yarn add mailtap 

Step 3: Send emails, below you’ll find minimal usage example.

const TOKEN = "<YOUR_API_TOKEN>";

const transport = Nodemailer.createTransport(
  MailtrapTransport({
    token: TOKEN,
  })
);

const sender = {
  address: "hello@demoatmailtrap.com",
  name: "Mailtrap Test",
};
const recipients = [
  "demo@mailtrap.io",
];

transport
  .sendMail({
    from: sender,
    to: recipients,
    subject: "You are awesome!",
    text: "Congrats for sending test email with Mailtrap!",
    category: "Integration Test",
  })
  .then(console.log, console.error);

For more information and examples, check the official GitHub repo

Supported functionality

  • Email sending – transitional and bulk 
  • Batch sending
  • Contacts and contacts lists management
  • Templates management 
  • Sending domains management
  • Sending and getting sandbox emails
  • Managing sandbox projects