Nodemailer
Send emails from Node.js applications with support for multiple transport methods.
3. Used by agents' projects
Dependency in 155 public GitHub projects set up for AI coding agents that we scanned (2.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
nodejs.org/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Nodemailer does
Nodemailer is a dependency-free Node.js mailer where the delivery method is a swappable part, and its README is blunt about setups that tend to fail, such as Gmail.
Nodemailer popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Nodemailer is used
- Nodemailer is a dependency in 155 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.2% of the 4,867 JavaScript/TypeScript ones), #3 of 281 in files, images and media.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 481; those are left out of every share on this page.
- Projects that use it most often also use dotenv (64.5%), Next.js (63.9%), Lucide React (63.2%).
- It is more common in projects set up for Devin Desktop (5.0%) than for OpenAI Codex (1.5%).
By coding agent
Often used with
Nodemailer in practice
Strengths
The site says everything ships in one package. There are no runtime dependencies or native addons, and no system libraries or build tools are needed.
The message code stays the same while the delivery method changes. Any transport that implements one <code>send(mail, callback)</code> method can be plugged in.
On success, the SMTP transport returns the accepted and rejected recipients, the server's EHLO capabilities, the message size, and timings for the envelope and the body.
Version 10 is written in TypeScript. Old type names such as <code>Mail.Options</code> keep compiling. The README says to remove <code>@types/nodemailer</code>.
Watch out for
Version 10 will not run on older Node.js. The docs say to stay on the 9.x line if you are on an older runtime.
The README says Gmail "either works well, or it does not work at all". It suggests that switching to another service is probably easier than fixing Gmail issues.
On Workers only the SMTP-based transports apply, because <code>sendmail</code> needs a child process. The README also says <code>tls.rejectUnauthorized: false</code> fails there with an error.
More about Nodemailer
Funding
- GitHub Sponsors: https://github.com/andris9
- Own page: https://www.paypal.me/nodemailer
- 7 GitHub sponsors
Packages around it
- dotenv: env file loader
- lucide-react: icon set for React
- next: React framework
- zod: schema validation
- tailwind-merge: Tailwind class merging
- clsx: className builder
Alternatives
Nodemailer This page
Get started
Install it.
npm install nodemailerRules for your agent
## Nodemailer
- Create one transporter when the application starts and reuse it. Do not call `createTransport()` for each message.
- Set `secure: true` only for port 465. Use `false` on every other port; Nodemailer still tries to upgrade to TLS if the server supports it.
- Read SMTP credentials from environment variables (`process.env.SMTP_USER`, `process.env.SMTP_PASS`), as the docs do.
- After `sendMail()`, check `info.rejected`. A message counts as sent if at least one recipient was accepted.
- On Nodemailer 10+, remove `@types/nodemailer` because types ship with the package. Import classes from `nodemailer/lib/*` with a default import.
- Target Node.js 20+. On Cloudflare Workers use only SMTP transports, and do not set `tls.rejectUnauthorized: false`, which fails there with an error.
- Call `await transporter.verify()` to catch configuration errors before sending.