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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-mandrill-wrapper

v1.0.0

Published

Mandrill API

Downloads

33

Readme

node-mandrill

A simple node.js wrapper for MailChimp's Mandrill API

Documentation

Usage

Constructor options

  • MANDRILL_API_KEY {String} api key value (can also be specified with environment variable MANDRILL_API_KEY)
  • DEFAULT_FROM_EMAIL {String} default from email (optional)
  • DEFAULT_FROM_NAME {String} default from name (optional)
  • DEFAULT_TEMPLATE_OPTIONS {Object} default template options (optional)

Methods

instance.send(options)

Return a fulfilled promise with mandrill response. See Below for options schema

instance.send(templateName, options)

Return a fulfilled promise with mandrill response. See Below for options schema

Options Schema

  • to {String/Array} email recipient or array of emails recipients
  • cc {String/Array} email carbon copy or array of emails carbon copies (optional)
  • bcc {String/Array} email blind carbon copy or array of emails blind carbon copies (optional)
  • subject {String} email subject (optional)
  • html {String} email HTML code (optional) (can be use only for send)
  • text {String} email text (optional) (can be use only for send)
  • global_merge_vars {Object} global merge vars, (optional) (see Mandrill documentation for more informations on it)
  • attachments {Array} array of attachments files (optional)

Examples

const Mandrill = require('node-mandrill');

const mailer = new Mandrill({
  MANDRILL_API_KEY: 'MY_MANDRILL_API_KEY',
  DEFAULT_FROM_EMAIL: '[email protected]',
  DEFAULT_FROM_NAME: 'no-reply',
  DEFAULT_TEMPLATE_OPTIONS: {
    global_merge_vars: [
      {'name': 'COMPANY', 'content': 'My Company'},
    ],
  },
});

mailer.send({
  to: '[email protected]',
  cc: '[email protected]',                          // optionnal
  bcc: ['[email protected]', '[email protected]'],   // optionnal
  subject: 'Reset Password Request',            // optionnal
  html: '<html>Test</html>', // html or text required
  text: 'Test',              // html or text required
}); // => return Promise


mailer.sendTemplate('PASSWORD_RESET_TEMPLATE', {
  to: '[email protected]',
  cc: '[email protected]',                              // optionnal
  bcc: ['[email protected]', '[email protected]'],       // optionnal
  subject: 'Reset Password Request',                // optionnal
  html: '<html>Test</html>',                        // optionnal
  text: 'Test',                                     // optionnal
  global_merge_vars: [
    {'name': 'PASSWORD_RESET_LINK', 'content': 'http://google.com'},
  ],
}); // => return Promise

Send attachments

const Mandrill = require('node-mandrill');
const fs = require('fs');

const mailer = new Mandrill(); // using MANDRILL_API_KEY defined in environment variable

mailer.send({
  to: ['[email protected]', '[email protected]']
  text: 'A file',
  attachments: [{
    type: 'application/pdf',
    name: 'Doc Name',
    content: new Buffer(fs.readFileSync('myDoc.pdf')).toString('base64'),
  }],
}); // => return Promise

TODO

  • unit test

Contributing

This project is a work in progress and subject to API changes, please feel free to contribute