nodemailer
The standard Node.js library for sending email — supports SMTP, OAuth2, and every major email provider with a simple, battle-tested API.
nodemailer
Node.jsThe standard Node.js library for sending email — supports SMTP, OAuth2, and every major email provider with a simple, battle-tested API.
Fit
Bundle (gzip)
60.6 kB
221.2 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Sending email from a Node.js app requires SMTP authentication, TLS negotiation, attachment handling, and HTML/plain-text multipart encoding — all complex to implement correctly from scratch.
What It Does
Nodemailer creates a transporter configured for your provider (Gmail, SendGrid, SMTP, etc.) and provides a sendMail method that handles encoding, headers, attachments, and delivery. It supports OAuth2 for Gmail, DKIM signing, embedded images, and HTML templating.
Installation
npm install nodemailer
npm install -D @types/nodemailerUsage Example
import nodemailer from 'nodemailer';
const transporter = nodemailer.createTransport({
host: 'smtp.sendgrid.net',
port: 587,
auth: { user: 'apikey', pass: process.env.SENDGRID_API_KEY },
});
await transporter.sendMail({
from: '"My App" <noreply@myapp.com>',
to: 'user@example.com',
subject: 'Welcome to My App!',
text: 'Thanks for signing up.',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
attachments: [{ filename: 'receipt.pdf', path: './receipts/receipt.pdf' }],
});Related packages
Role and attribute based access control (RBAC + ABAC) for Node.js with a fluent, readable API.
bcryptjsNode.jsPure JavaScript bcrypt password hashing — no native dependencies, same API as bcrypt, works anywhere Node.js runs.
bullmqNode.jsPremium message queue and job scheduler for Node.js backed by Redis — reliable background job processing with retries, priorities, and rate limiting.
casbinNode.jsA powerful authorization library that supports RBAC, ABAC, ACL and more via configurable policy models.
dotenvNode.jsLoad environment variables from a `.env` file into `process.env` — the standard way to manage configuration in Node.js apps.