node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A Mandrill transport for Nodemailer.

Build Status Coverage Status npm version Dependency Status devDependency Status


'use strict';
var nodemailer = require('nodemailer');
var mandrillTransport = require('nodemailer-mandrill-transport');
var transport = nodemailer.createTransport(mandrillTransport({
  auth: {
    apiKey: 'key'
  from: '',
  to: '',
  subject: 'Hello',
  html: '<p>How are you?</p>'
}, function(err, info) {
  if (err) {
  } else {

Using Mandrill API options

It is possible to use any Messages Send Mandrill API option by passing it into the mandrillOptions option. These will be deeply merged over the API call this transport builds for you. For example, this transport enables the async option by default. To disable this,

  mandrillOptions: {
    async: false
}, /* ... */);

Sending Images to Mandrill

To send images as attachments:

  mandrillOptions: {
    images: [
      'type': 'image/png',
      'name': 'IMAGECID',
      'content': 'ZXhhbXBsZSBmaWxl',
}, /* ... */);

name: image cid:

Reference your attached image in your HTML:

<img src="IMAGECID">

Make sure to use unique cids for your images!

content: a base64 representation of your image.

var fs = require('fs');
var imgBuff = fs.readFileSync('path/to/file');

Using Mandrill Templates

To send email using templates stored on Mandrill:

  mandrillOptions: {
    template_name: 'MANDRILL_TEMPLATE_SLUG'
}, /* ... */);