
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
nodemailer-templation
Advanced tools
A Nodemailer wrapper for easily sending HTML templated emails.
I've always had problems trying to send emails via multiple HTML templates. There really wasn't anything that solved all of my needs in a way that was easy and made sense to me. I found a code snippit some where for node 0.8x, that didn't work, so I adapted it into this package.
Install via Download,
NPM (recommended)
npm install --save nodemailer-templation
You need an external SMTP server or service to make this work. I recommend Mandrill. Its free, and fast.
Example using mandrill as our SMTP service.
var Templation = require('nodemailer-templation');
var path = require('path');
//Create our new new mailer object
var Mailer = new Templation({
from: 'hello@example.com',
templates: {
reply: path.resolve(__dirname, '../templates/reply.html')
},
attachments: [
{
filename: 'logoLite.png',
path: path.resolve(__dirname, '../templates/images/logoLite.png'),
cid: 'light@logo'
},
{
filename: 'logoDark.png',
path: path.resolve(__dirname, '../templates/images/logoDark.png'),
cid: 'dark@logo'
}
],
transportOptions: {
host: 'smtp.mandrillapp.com',
port: 587,
auth: {
user: 'SomeUserName',
pass: 'SomeUserNameAPIKEY'
}
}
});
//Send a mail using a template you've created, and listed under the templates option above.
Mailer.send({
to: 'acoolguy@google.com',
subject: 'Hello World',
template: 'reply',
messageData: {
title: 'Hello Dude',
name: 'Woah',
message: 'Far Out'
}
});
//Send a mail using the default template
Mailer.send({
to: 'a2coolguy@google.com',
subject: 'Hello World',
messageData: {
title: 'Hello Dude',
name: 'Woah',
message: 'Far Out',
copymark: '(c) TooCool LLC 1995'
}
});
There are the options you can send in when you create your new Templation object.
attachments (array) of objects
var attachments = [
{
filename: 'logoLite.png',
path: path.resolve(__dirname, '../templates/images/logoLite.png'),
cid: 'light@logo' //used in your template when you send emails.
}
];
/* Example including above logo attachment
<img src="cid:light@logo" alt="My Company LLC.">
*/
transportOptions object (required)
nodemailer-smtp-transport options.
You can either set this to be used for all templates, or send in a transportOptions field when you
use the send() method below.
var transportOptions = {
host: 'smtp.mandrillapp.com',
port: 587,
auth: {
user: 'SomeUserName',
pass: 'SomeUserNameAPIKEY'
}
};
These are the options when you send using your Template object
var Mailer = new Templation(templationOptions);
Mailer.send(mailerOptions);
to object or string (required)
var to = { //equivalent to "Bruce Wayne <iamnotbatman@wayne.com>"
name: 'Bruce Wayne',
email: 'iamnotbatman@wayne.com'
};
//OR
var to = "iamnotbatman@wayne.com";
from string (see above)
subject string (required)
var subject = 'TPS Reports';
template string
The name of the template if you defined one above, or a (string) path to a template.html file
var template = 'report';
//OR
var template = path.resolve(__dirname, '/someTemplate.html');
messageData object
Corresponding fields to what is inside of the template.html file
var messageData = {
title: 'Hello Dude',
name: 'Woah',
message: 'Far Out',
copymark: '(c) TooCool LLC 1995'
};
transportOptions object (see above)
FAQs
Nodemailer wrapper for easily sending HTML templated emails
The npm package nodemailer-templation receives a total of 1 weekly downloads. As such, nodemailer-templation popularity was classified as not popular.
We found that nodemailer-templation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.