Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mandrill-nodemailer-transport with all npm packages installed. Try it out:

require("nodemailer/package.json"); // nodemailer is a peer dependency. var mandrillNodemailerTransport = require("mandrill-nodemailer-transport")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mandrill-nodemailer-transport v1.0.1

Mandrill API and Nodemailer v4+. The plugin is very small, optimized and written in TypeScript

mandrill-nodemailer-transport

Intro

The custom transport plugin that allows to send email using Nodemailer via Mandrill

Why?

Created for the new Mandrill API and Nodemailer v4+. The plugin is very small, optimized and written in TypeScript

Support the project

If you like to use this module please click the star button - it is very motivating.

Quick Start

Install mandrill-nodemailer-transport using npm:

$ npm install mandrill-nodemailer-transport --save

Documentation

Nodemailer common fields are supported and replyTo

Examples

send simple email

  'use strict';
  const nodemailer = require('nodemailer');
  const MandrillTransport = require('mandrill-nodemailer-transport');

  let transporter = nodemailer.createTransport(new MandrillTransport({
    apiKey: '12124124124124-key-test'
  }));

  transporter.sendMail({
    from: 'email@example.com',
    to: 'recipient@test.com',
    replyTo: 'reply-to@example.com',
    subject: 'Mandrill Transport',
    text: 'This is text content'
  }).then((info) => {
    console.log('SUCCESS');
  }).catch((error) => {
    console.log('Something is wrong');
  });

send attachment and add to content

  'use strict';
  const nodemailer = require('nodemailer');
  const MandrillTransport = require('mandrill-nodemailer-transport');

  let transporter = nodemailer.createTransport(new MandrillTransport({
    apiKey: '12124124124124-key-test'
  }));

  transporter.sendMail({
    from: 'email@example.com',
    to: 'recipient@test.com',
    replyTo: 'reply-to@example.com',
    subject: 'Mandrill Transport',
    html: '<!DOCTYPE html><html><body><img src="cid:attachment" alt="attachment"></body></html>',
    attachments: [{
      content: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAA...', // base64 content
      cid: 'attachment',
      contentType: 'image/jpeg',
      filename: 'attachment.jpg',
      encoding: 'base64'
    }]
  }).then((info) => {
    console.log('SUCCESS');
  }).catch((error) => {
    console.log('Something is wrong');
  });

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free