API Reference

Nodemailer

Node.js module for sending email through any SMTP server, with HTML bodies, attachments, and OAuth2 support.

Official Documentation ↗
CompatibilityThis documentation covers version v6.9. Check the official docs for the latest API surface.

Installation

npmnpm install nodemailer

Methods

Nodemailer builds MIME messages and delivers them over SMTP, SES, or a JSON transport, exposing a promise-based API.

Key Features

  • Zero runtime dependencies and a single transport abstraction
  • Rich mail options: HTML, text, attachments, and raw messages
  • OAuth2 and DKIM signing for production deliverability

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

Does Nodemailer require a paid email service?
No. Nodemailer talks to any SMTP server you already have, including self-hosted Postfix, Amazon SES, or Gmail with an app password.
How do I send HTML email with attachments?
Pass an html string in the mail options and an attachments array whose entries contain filename plus path or content.
Is Nodemailer safe for serverless?
Yes, but each invocation that creates a transport opens a new connection. Create the transport once per process and reuse it to avoid extra handshakes.