@nestjs-modules/mailer
A NestJS module that wraps Nodemailer with templates, queues, and DI-friendly config
Repository Health
Technical Analysis
@nestjs-modules/mailer wraps Nodemailer inside a standard NestJS module, so sending email becomes an injectable MailerService instead of a hand-rolled Nodemailer transporter wired up outside the DI container. It supports both synchronous and async module registration (forRoot/forRootAsync), multiple named transports, and pluggable template adapters (Handlebars, Pug, EJS) for rendering HTML emails from files.
A mailer-queue companion module adds Bull/BullMQ-backed queued sending for cases where email dispatch shouldn’t block the request/response cycle, plus event hooks and a health-check integration for monitoring mail delivery. The project lives as a small monorepo (packages/mailer) maintained under the nest-modules GitHub organization.
What You Get
- An injectable
MailerServicewithsendMail()returning a promise, fully integrated into Nest’s DI container forRoot()/forRootAsync()module registration matching NestJS’s standard configuration pattern- Pluggable template adapters (Handlebars, Pug, EJS via
TemplateAdapterinterface) for rendering email bodies from template files - Multiple named transporter support for sending from different accounts/providers within one app
- An optional
mailer-queuemodule for Bull/BullMQ-backed asynchronous, queued email sending
Common Use Cases
- Sending transactional emails (welcome, password reset, order confirmation) from a NestJS backend via dependency injection
- Rendering HTML email templates with dynamic data using Handlebars/Pug/EJS instead of string-concatenating markup
- Queuing outbound email through Bull/BullMQ so email delivery doesn’t block API request handling
- Running multiple mail transports (e.g. transactional vs. marketing) from a single NestJS application
Under The Hood
Architecture - the module’s core lives in packages/mailer/lib/: mailer.module.ts wires DI providers together, mailer-transport.factory.ts builds Nodemailer transporters from MailerOptions, mailer.service.ts exposes the public sendMail() API and delegates HTML rendering to a configured TemplateAdapter, and a separate mailer-queue.module.ts/mailer-queue.service.ts/mailer-queue.processor.ts trio adds Bull-based queued dispatch as an optional add-on, with mailer-event.service.ts emitting lifecycle events and a health/ submodule for delivery health checks. Tech Stack - TypeScript on top of @nestjs/common, Nodemailer for actual SMTP/transport delivery, lodash for options merging (defaultsDeep), managed as a pnpm/Turborepo monorepo with Biome for linting/formatting and changesets for releases. Code Quality - 9 spec files (mailer.service.spec.ts, mailer-transport.factory.spec.ts, mailer-queue.module.spec.ts, etc.) exercise the 41 library source files via Jest, and the module handles optional dependencies gracefully (e.g. warning rather than crashing when the optional preview-email package isn’t installed). API Design - the API mirrors NestJS conventions closely (forRoot/forRootAsync, @Injectable() services, DI tokens like MAILER_OPTIONS), so developers already familiar with NestJS modules can wire up mail sending with minimal new concepts to learn beyond choosing a template adapter.
Used by 3 apps in this directory
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Swetrix
Analytics
Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.