<commit_before># [**email-templates**](https://github.com/niftylettuce/email-templates)

[![build status](https://img.shields.io/travis/niftylettuce/email-templates.svg)](https://travis-ci.org/niftylettuce/email-templates)
[![code coverage](https://img.shields.io/codecov/c/github/niftylettuce/email-templates.svg)](https://codecov.io/gh/niftylettuce/email-templates)
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
[![license](https://img.shields.io/github/license/niftylettuce/email-templates.svg)](LICENSE)

> Create, [preview][preview-email], and send custom email templates for [Node.js][node]. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for sending beautiful emails with [Lad][].
>
> **NEW**: v3.x is released (you'll need Node v6.4.0+); see [breaking changes below](#v3-breaking-changes). [2.x branch][2-x-branch] docs available if necessary.


## Table of Contents

* [Install](#install)
* [Preview](#preview)
* [Usage](#usage)
  * [Basic](#basic)
  * [Automatic Inline CSS via Stylesheets](#automatic-inline-css-via-stylesheets)
  * [Cache Pug Templates](#cache-pug-templates)
  * [Localization](#localization)
  * [Custom Text Template](#custom-text-template)
  * [Custom Template Engine (e.g. EJS)](#custom-template-engine-eg-ejs)
  * [Custom Default Message Options](#custom-default-message-options)
  * [Custom Rendering (e.g. from a MongoDB database)](#custom-rendering-eg-from-a-mongodb-database)
* [Options](#options)
* [Plugins](#plugins)
* [V3 Breaking Changes](#v3-breaking-changes)
* [Tip](#tip)
* [Contributors](#contributors)
* [License](#license)


## Install

> By default we recommend [pug][] for your template engine, but you can use [any template engine][supported-engines].

[npm][]:

```sh
npm install email-templates pug
```

[yarn][]:

```sh
yarn add email-templates pug
```


## Preview

We've added [preview-email][] by default to this package!

This means that (by default) in the development environment (e.g. `NODE_ENV=development`) your emails will be rendered to the tmp directory for you and automatically opened in the browser.

<a target="_blank" href="https://github.com/niftylettuce/preview-email/blob/master/demo.png">View the demo</a>


## Usage

> **UPGRADING?** If you are upgrading from v2 to v3, see [v3 Breaking Changes](#v3-breaking-changes) below.  You'll need Node v6.4.0+ now for Promises and async/await support.

### Basic

> You can swap the `transport` option with a [Nodemailer transport][nodemailer-transport] configuration object or transport instance. We highly recommend using [Postmark][] for your transport (it's the default in [Lad][]).
>
> If you want to send emails in `development` or `test` environments, set `options.send` to `true`.

```js
const Email = require('email-templates');<commit_msg>Fixed typo<commit_after># [**email-templates**](https://github.com/niftylettuce/email-templates)

[![build status](https://img.shields.io/travis/niftylettuce/email-templates.svg)](https://travis-ci.org/niftylettuce/email-templates)
[![code coverage](https://img.shields.io/codecov/c/github/niftylettuce/email-templates.svg)](https://codecov.io/gh/niftylettuce/email-templates)
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
[![license](https://img.shields.io/github/license/niftylettuce/email-templates.svg)](LICENSE)

> Create, [preview][preview-email], and send custom email templates for [Node.js][node]. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for sending beautiful emails with [Lad][].
>
> **NEW**: v3.x is released (you'll need Node v6.4.0+); see [breaking changes below](#v3-breaking-changes). [2.x branch][2-x-branch] docs available if necessary.


## Table of Contents

* [Install](#install)
* [Preview](#preview)
* [Usage](#usage)
  * [Basic](#basic)
  * [Automatic Inline CSS via Stylesheets](#automatic-inline-css-via-stylesheets)
  * [Cache Pug Templates](#cache-pug-templates)
  * [Localization](#localization)
  * [Custom Text Template](#custom-text-template)
  * [Custom Template Engine (e.g. EJS)](#custom-template-engine-eg-ejs)
  * [Custom Default Message Options](#custom-default-message-options)
  * [Custom Rendering (e.g. from a MongoDB database)](#custom-rendering-eg-from-a-mongodb-database)
* [Options](#options)
* [Plugins](#plugins)
* [V3 Breaking Changes](#v3-breaking-changes)
* [Tip](#tip)
* [Contributors](#contributors)
* [License](#license)


## Install

> By default we recommend [pug][] for your template engine, but you can use [any template engine][supported-engines].

[npm][]:

```sh
npm install email-templates pug
```

[yarn][]:

```sh
yarn add email-templates pug
```


## Preview

We've added [preview-email][] by default to this package!

This means that (by default) in the development environment (e.g. `NODE_ENV=development`) your emails will be rendered to the tmp directory for you and automatically opened in the browser.

<a target="_blank" href="https://github.com/niftylettuce/preview-email/blob/master/demo.png">View the demo</a>


## Usage

> **UPGRADING?** If you are upgrading from v2 to v3, see [v3 Breaking Changes](#v3-breaking-changes) below.  You'll need Node v6.4.0+ now.

### Basic

> You can swap the `transport` option with a [Nodemailer transport][nodemailer-transport] configuration object or transport instance. We highly recommend using [Postmark][] for your transport (it's the default in [Lad][]).
>
> If you want to send emails in `development` or `test` environments, set `options.send` to `true`.

```js
const Email = require('email-templates');
{'fraction_non_alphanumeric': 0.16376250403355921, 'fraction_numerical': 0.008389803162310423, 'mean_word_length': 5.377572016460905, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 26, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6828094', 'n_tokens_mistral': 2143, 'n_tokens_neox': 1991, 'n_words': 497}