This folder contains HTML templates for transactional email, each template in its own folder. For example:
.
├── /welcome/ # The email template for sending a welcome message
│ ├── /html.hbs # The HTML version of the message
│ └── /subject.hbs # The subject of the email
└── layout.hbs # Layout markup (header, footer etc.)
For testing purposes, there is /emails/:template
endpoint (see src/app.js
) that you can
use for testing these templates in a browser. For example, in order to see how the welcome
template renders in a browser simply navigate to:
https://localhost:8080/emails/welcome
All the templates in this folder are pre-compiled at build time (see tools/build.js
)
and consumed by the email
component (see src/email.js
).
import email from './email';
app.get('/test', async (req, res) => {
const message = email.render('welcome', { t: req.t });
await email.send(message, { to: '[email protected]' });
res.send('Sent');
});
- Nodemailer a Node.js module for sending email messages
- Juice library for inlining CSS stylesheets into HTML sources
- Handlebars template engine that is well suited for writing email templates
- Handlebars Layouts a plugin for Handlebars that adds layout support
- Responsive HTML Email template by by Lee Munroe