Nodemailer
22 June 2025 (Updated 22 June 2025)
On this page
What is Nodemailer?
Nodemailer lets you send emails using Node.js.
Quickstart
Install package:
npm install nodemailer
Send email:
const nodemailer = require("nodemailer");
// 1. Create a test account or replace with real credentials.
const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "maddison53@ethereal.email",
pass: "jn7jnAPss4f63QBp6D",
},
});
// 2. Wrap in an async IIFE so we can use await and send.
(async () => {
const info = await transporter.sendMail({
from: '"Maddison Foo Koch" <maddison53@ethereal.email>',
to: "bar@example.com, baz@example.com",
subject: "Hello ✔",
text: "Hello world?", // plain‑text body
html: "<b>Hello world?</b>", // HTML body
});
console.log("Message sent:", info.messageId);
})();
Tagged:
Node.js tooling