Nodemailer

The zero-dependency Node.js library for sending email over SMTP, SES, sendmail, and more.

Library
npm
v10.2.1
17,689 stars
MIT-0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
89 /100 Excellent
Development Activity 96
Maintenance 84
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
82 /100 Excellent
Architecture 85
Code Quality 88
Innovation 78
Learning Curve 75

Nodemailer is the de facto standard library for sending email from Node.js applications, downloaded millions of times a week with zero runtime dependencies. It ships pluggable transports for direct SMTP delivery, connection pooling, Amazon SES, sendmail, and test-friendly JSON/stream output, all wrapped behind one consistent createTransport() API.

Beyond raw delivery, Nodemailer handles the parts developers usually get wrong by hand: MIME multipart composition with attachments and embedded images, DKIM signing, RFC 5322 address parsing, and OAuth2 authentication for Gmail and Outlook. The library has shipped since 2011, stayed committed to CommonJS and Node 6+ compatibility for maximum embeddability, and remains under active, security-conscious maintenance by its original author.

What You Get

  • One createTransport() entry point that auto-detects and dispatches to SMTP, SMTP pool, SES, sendmail, stream, or JSON transports based on the options passed in.
  • A full MIME composer (lib/mail-composer, lib/mime-node) that builds multipart messages with attachments, inline images, and calculated Content-Type boundaries without extra dependencies.
  • Built-in DKIM signing (lib/dkim) so outgoing mail can be cryptographically signed without a separate library.
  • An RFC 5322-compliant address parser (lib/addressparser) that turns free-form ‘Name <email>’ strings and comma-separated lists into structured recipient objects.
  • OAuth2 token handling (lib/xoauth2) for authenticating against Gmail and Outlook/Office 365 without storing a static password.

Common Use Cases

  • Transactional email from a Node.js backend — password resets, order confirmations, signup verification — sent over SMTP or Amazon SES.
  • Local development and CI, using the streamTransport or jsonTransport options to capture composed messages without touching a live mail server.
  • High-volume sending through SMTPPool, which keeps persistent connections open and rate-limits outbound messages against a provider’s throughput cap.
  • OAuth2-authenticated sending through Gmail or Microsoft 365 accounts, avoiding app passwords or storing raw account credentials.

Under The Hood

Architecture

Nodemailer’s entry point, lib/nodemailer.js, exposes a single createTransport(transporter, defaults) function that inspects the passed options (or a smtp://…/direct: connection URL parsed via lib/shared) and dispatches to one of six bundled transport constructors — SMTPTransport, SMTPPool, SESTransport, SendmailTransport, StreamTransport, or JSONTransport — before wrapping the result in a Mail instance from lib/mailer/index.js. Mail (an EventEmitter subclass) is the layer every message actually flows through: it normalizes the caller’s message object, invokes the DKIM signer (lib/dkim) when configured, and calls MailComposer (lib/mail-composer) to walk the recipient/attachment data into a MIME tree via lib/mime-node before handing the resulting stream to the transport’s own send(mail, callback) method — a duck-typed contract requiring only name, version, and send(). The one genuinely hot, security-sensitive path is lib/smtp-connection/index.js (2000+ lines), a hand-rolled SMTP/LMTP/ESMTP client that owns socket lifecycle, STARTTLS negotiation, and line-buffered response parsing, including a documented binary-container trick (decodeServerResponse) to reassemble multi-byte UTF-8 server replies split across TCP chunks. Supporting concerns — address parsing (lib/addressparser), OAuth2 token generation (lib/xoauth2), punycode domain handling, and MIME/base64/quoted-printable encoding — are each isolated into their own single-purpose lib/ subdirectory.

Tech Stack

The package declares zero runtime dependencies in package.json — every SMTP, MIME, DKIM, and OAuth2 concern is implemented in-house rather than delegated to third-party packages, a deliberate constraint stated in the project’s own CLAUDE.md. It targets Node.js >=6.0.0 and is written as strict CommonJS in ES2017 script mode: no ESM import, no optional chaining, no class fields, enforced by an ESLint config pinned to ecmaVersion 2017 and sourceType ‘script’, plus a dedicated test:syntax script that runs the suite inside a node:6-alpine Docker container to catch accidental modern syntax. Formatting is Prettier-managed, linting is ESLint 10 with eslint-config-prettier to avoid rule overlap, and releases are fully automated by the release-please GitHub Action, which derives version bumps and CHANGELOG.md entries from Conventional Commit messages on master rather than manual tagging.

Code Quality

Testing is substantial: 39 dedicated *-test.js files under test/, mirroring the lib/ directory 1:1, run via Node’s native node —test runner (~480+ assertions, ~150s, serial execution) with c8 for coverage. Most SMTP-facing suites (test/smtp-connection, test/smtp-transport, test/smtp-pool) spin up real smtp-server instances on ephemeral ports rather than mocking the protocol, and some drop to raw net servers when a test needs byte-exact control over server replies, such as injecting invalid UTF-8 to exercise decodeServerResponse’s fallback path. The project’s own contribution guidance is explicit that security-sensitive code — lib/smtp-connection, address parsing, header generation, DKIM — requires tests exercising the failure mode, not just the happy path, reflecting real awareness of SMTP command-injection risk from user-controllable envelope/header values. Naming is consistent camelCase/PascalCase throughout, ‘use strict’ is present at the top of every file, and inline JSDoc comments document option objects on public constructors.

API Design The public surface is intentionally small: one createTransport() factory that accepts either an options object or a smtp://…/direct: connection string, returning a Mail instance whose only method callers typically touch is sendMail(). The library still exposes a callback-first API throughout (transporter.sendMail(options, callback)), with promise support layered on top only when no callback is supplied — a deliberate legacy-compatible design choice rather than an oversight, and one the project explicitly asks contributors not to convert wholesale. Getting started requires no more than an options object and one sendMail() call, and swapping the underlying transport (SMTP to SES to a test JSON transport) is a one-line change to the constructor input with no change to calling code. The tradeoff for this stability is limited native TypeScript support — types are maintained separately as @types/nodemailer rather than shipped in-tree — and callback-based internals that read as dated next to newer promise/async-first libraries.

Used by 107 apps in this directory

TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,733

Open-source AI agent monitoring that catches what will break next before your users do.

View details
87
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Python 11%
Rust 11%
Updated 1 weeks ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,629

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
45
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
TypeScript
85%
MIT

LibreChat

AI Assistants · Developer Tools

46,236

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
62
Dependency
Built with
TypeScript 85%
JavaScript 14%
Updated 6 days ago
TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,196

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
93%
AGPL 3.0

Linkwarden

Bookmarks Archiving · Knowledge Management

20,195

Self-hosted collaborative bookmark manager that captures full-page archives, enables annotation, and keeps your knowledge accessible forever.

View details
90
Repo Health
72
Technical
66
Dependency
Built with
TypeScript 93%
Updated 6 days ago
TypeScript
98%
Other

LobeHub

AI Assistants · Automation · Productivity

83,455

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
71%
Other

LogChimp

Marketing · Product Management

1,132

Collect customer feedback, prioritize features with upvotes, and build transparent product roadmaps — fully self-hosted and open source.

View details
83
Repo Health
77
Technical
72
Dependency
Built with
TypeScript 71%
Vue 27%
Updated 1 weeks ago
TypeScript
98%
MPL 2.0

Logto

Authentication

14,769

Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC

View details
92
Repo Health
83
Technical
63
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
99%
AGPL 3.0

Manage

Collaboration · Project Management

71

Self-hosted, open-source project management with tasks, calendars, docs, and real-time team collaboration.

View details
33
Repo Health
57
Technical
71
Dependency
Built with
TypeScript 99%
Updated 2 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers