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
98%
Other

GrowthBook

Ab Testing Experimentation · Analytics · Developer Tools

8,527

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

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

Hexabot

AI Development · Automation

1,160

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
76
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 98%
Updated 1 months ago
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

9,048

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
86
Repo Health
67
Technical
67
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

483

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
68
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 1 weeks ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
TypeScript
96%
Other

Infisical

Devops · Security

29,961

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
93%
Apache 2.0

InsForge

Databases · Developer Tools

13,176

The all-in-one, open-source backend platform purpose-built for AI coding agents — giving your agent database, auth, storage, edge functions, a model gateway, and compute to ship full-stack apps end-to-end.

View details
86
Repo Health
81
Technical
72
Dependency
Built with
TypeScript 93%
Updated 6 days 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