npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nodemailer-templation

v0.1.4

Published

Nodemailer wrapper for easily sending HTML templated emails

Readme

nodemailer-templation

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.

Installation

Install via Download,

NPM (recommended)

npm install --save nodemailer-templation

Useage

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: '[email protected]',
    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: '[email protected]',
  subject: 'Hello World',
  template: 'reply',
  messageData: {
    title: 'Hello Dude',
    name: 'Woah',
    message: 'Far Out'
  }
});

//Send a mail using the default template
Mailer.send({
  to: '[email protected]',
  subject: 'Hello World',
  messageData: {
    title: 'Hello Dude',
    name: 'Woah',
    message: 'Far Out',
    copymark: '(c) TooCool LLC 1995'
  }
});

Templation Options

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'
  }
};

Templation.send() Method Options

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 <[email protected]>"
  name: 'Bruce Wayne',
  email: '[email protected]'
};

//OR

var to = "[email protected]";

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)