# @nestjs-modules/mailer

> NestJS - a mailer module (@mailer)

Latest version **2.3.7** (published 2026-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nestjs-modules/mailer
pnpm add @nestjs-modules/mailer
yarn add @nestjs-modules/mailer
bun add @nestjs-modules/mailer
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.3.7 |
| Published | 2026-06-17 |
| First published | 2020-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 114 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | Nest Modules TM |
| Maintainers | juandav |
| Keywords | nest, nodemailer, mailer, nodejs |

## Links

- npm: https://www.npmjs.com/package/@nestjs-modules/mailer
- Repository: https://github.com/nest-modules/mailer
- Homepage: https://github.com/nest-modules/mailer#readme
- Issues: https://github.com/nest-modules/mailer/issues
- npm.io page: https://npm.io/package/@nestjs-modules/mailer

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) 13.0.6
- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [@css-inline/css-inline](https://npm.io/package/@css-inline/css-inline.md) 0.20.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.3.7 (latest) — 2026-06-17
- 2.3.6 — 2026-05-19
- 2.3.5 — 2026-05-18
- 2.3.4 — 2026-03-25
- 2.3.3 — 2026-03-25
- 2.3.2 — 2026-03-25
- 2.3.1 — 2026-03-25
- 2.3.0 — 2026-03-21
- 2.2.0 — 2026-03-21
- 2.1.19 — 2026-03-21
- 2.1.18 — 2026-03-21
- 2.1.17 — 2026-03-21
- 2.1.16 — 2026-03-21
- 2.1.15 — 2026-03-21
- 2.1.14 — 2026-03-21
- … 42 more at https://npm.io/package/@nestjs-modules/mailer/versions

## README

<p align="center">
  <a href="http://nestjs.com/" target="blank">
    <img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" />
  </a>
</p>

<p align="center">
  A mailer module for <a href="http://nestjs.com/">NestJS</a> using <a href="https://nodemailer.com/">Nodemailer</a>
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/@nestjs-modules/mailer"><img src="https://img.shields.io/npm/v/@nestjs-modules/mailer.svg" alt="NPM Version" /></a>
  <a href="https://www.npmjs.com/package/@nestjs-modules/mailer"><img src="https://img.shields.io/npm/l/@nestjs-modules/mailer.svg" alt="Package License" /></a>
  <a href="https://www.npmjs.com/package/@nestjs-modules/mailer"><img src="https://img.shields.io/npm/dm/@nestjs-modules/mailer.svg" alt="NPM Downloads" /></a>
</p>

## Features

- **Built on Nodemailer** — Supports SMTP, SES, sendmail, and more.
- **Multiple Template Engines** — Handlebars, Pug, EJS, Liquid, or MJML.
- **NestJS Native** — Dependency injection, async configuration, and module patterns.
- **Multiple Transporters** — Configure multiple SMTP servers and switch per message.
- **CSS Inlining** — Built-in css-inline ensures emails render correctly across all clients.
- **Preview Emails** — Preview emails in the browser during development.

## Documentation

Full documentation is available at **[nest-modules.github.io/mailer](https://nest-modules.github.io/mailer/)**.

## Installation

```bash
pnpm add @nestjs-modules/mailer nodemailer
```

Install a template engine of your choice:

```bash
pnpm add handlebars
# or
pnpm add pug
# or
pnpm add ejs
```

## Quick Start

```typescript
// app.module.ts
import { Module } from '@nestjs/common';
import { MailerModule } from '@nestjs-modules/mailer';
import { HandlebarsAdapter } from '@nestjs-modules/mailer/adapters/handlebars.adapter';

@Module({
  imports: [
    MailerModule.forRoot({
      transport: {
        host: 'smtp.example.com',
        port: 587,
        auth: {
          user: 'username',
          pass: 'password',
        },
      },
      defaults: {
        from: '"No Reply" <noreply@example.com>',
      },
      template: {
        adapter: new HandlebarsAdapter(),
      },
    }),
  ],
})
export class AppModule {}
```

```typescript
// example.service.ts
import { Injectable } from '@nestjs/common';
import { MailerService } from '@nestjs-modules/mailer';

@Injectable()
export class ExampleService {
  constructor(private readonly mailerService: MailerService) {}

  async sendEmail() {
    await this.mailerService.sendMail({
      to: 'user@example.com',
      subject: 'Hello',
      template: 'welcome',
      context: {
        name: 'John',
      },
    });
  }
}
```

## Contributing

Contributions are welcome! See the [documentation](https://nest-modules.github.io/mailer/) for details on the monorepo structure and development commands.

### Contributors

- [Cristiam Diaz](https://github.com/cdiaz)
- [Eduardo Leal](https://github.com/eduardoleal)
- [Juan Echeverry](https://github.com/juandav)
- [Pat McGowan](https://github.com/p-mcgowan)
- [Paweł Partyka](https://github.com/partyka95)
- [Wasutan Kitijerapat](https://github.com/kitimark)
- [Alexandre Titeux](https://github.com/GFoniX)

## License

MIT

---
_Source: https://npm.io/package/@nestjs-modules/mailer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
