# nodemailer-express-handlebars

> A plugin for nodemailer that uses express-handlebars view engine to generate emails

Latest version **7.0.0** (published 2024-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install nodemailer-express-handlebars
pnpm add nodemailer-express-handlebars
yarn add nodemailer-express-handlebars
bun add nodemailer-express-handlebars
```

## Health

**Score 28/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2024-09-11 |
| First published | 2014-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/nodemailer-express-handlebars) |
| Module format | ESM + CommonJS |
| Node | >= 20 |
| Dependencies | 0 |
| Unpacked size | 4.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91 |
| Author | Vadim Kazakov |
| Maintainers | yads |
| Keywords | nodemailer, html, express-handlebars, handlebars |

## Links

- npm: https://www.npmjs.com/package/nodemailer-express-handlebars
- Repository: https://github.com/yads/nodemailer-express-handlebars
- Issues: https://github.com/yads/nodemailer-express-handlebars/issues
- npm.io page: https://npm.io/package/nodemailer-express-handlebars

## 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

- 7.0.0 (latest) — 2024-09-11
- 6.1.2 — 2024-02-12
- 6.1.1 — 2024-02-12
- 6.1.0 — 2023-03-06
- 6.0.0 — 2022-12-13
- 5.0.0 — 2022-02-28
- 4.0.0 — 2020-03-26
- 3.3.0 — 2020-03-19
- 3.2.0 — 2020-03-19
- 3.1.0 — 2019-07-19
- 3.0.0 — 2018-02-12
- 2.0.0 — 2016-03-08
- 1.0.0 — 2015-05-22
- 0.0.3 — 2014-12-19
- 0.0.2 — 2014-11-13
- … 1 more at https://npm.io/package/nodemailer-express-handlebars/versions

## README

# Express Handlebars plugin for Nodemailer
This plugin works with nodemailer 6.x. And uses the [express-handlebars](https://github.com/express-handlebars/express-handlebars) view
engine to generate html emails.

# Install from npm
```bash
npm install nodemailer-express-handlebars
```
# Usage
```javascript
//reference the plugin
import hbs from 'nodemailer-express-handlebars';
//attach the plugin to the nodemailer transporter
transporter.use('compile', hbs(options));
//send mail with options
const mail = {
   from: 'from@domain.com',
   to: 'to@domain.com',
   subject: 'Test',
   template: 'email',
   context: {
       name: 'Name'
   }
}
transporter.sendMail(mail);
```

You can send a multipart html and text email by setting the `text_template` option on a mail message.
```javascript
const mail = {
   from: 'from@domain.com',
   to: 'to@domain.com',
   subject: 'Test',
   template: 'email',
   text_template: 'text',
   context: {
       name: 'Name'
   }
}
```
## Plugin Options
The plugin expects the following options:
* __viewEngine (required)__ either the express-handlebars view engine instance or [options for the view engine](https://github.com/express-handlebars/express-handlebars#configuration-and-defaults)
* __viewPath (required)__ provides the path to the directory where your views are
* __extName__ the extension of the views to use (defaults to `.handlebars`)

## Mail options
Set the template and values properties on the mail object before calling `sendMail`
* __template__ the name of the template file to use
* __context__ this will be passed to the view engine as the context as well as view engine options see [here](https://github.com/express-handlebars/express-handlebars#renderviewviewpath-optionscallback-callback)

# License
MIT

---
_Source: https://npm.io/package/nodemailer-express-handlebars · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
