Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

matter-app/nodemailer-postmark-transport

 
 

Repository files navigation

nodemailer-postmark-transport

A Postmark transport for Nodemailer.

Build Status Coverage Status Dependency Status npm version

Requirements

  • Node.js 4+

Note: If you node version is less than 4 should use [email protected]

Install

npm install nodemailer-postmark-transport

Examples

Quick start

'use strict';

const nodemailer = require('nodemailer');
const postmarkTransport = require('nodemailer-postmark-transport');
const transport = nodemailer.createTransport(postmarkTransport({
  auth: {
    apiKey: 'key'
  }
}));
const mail = {
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello',
  text: 'Hello',
  html: '<h1>Hello</h1>'
};

transport.sendMail(mail, function (err, info) {
  if (err) {
    console.error(err);
  } else {
    console.log(info);
  }
});

Use Postmark templates feature

Read about Postmark templates here: Special delivery: Postmark templates

'use strict';

const nodemailer = require('nodemailer');
const postmarkTransport = require('nodemailer-postmark-transport');
const transport = nodemailer.createTransport(postmarkTransport({
  auth: {
    apiKey: 'key'
  }
}));
const mail = {
  from: '[email protected]',
  to: '[email protected]',
  templateId: 1234,
  templateModel: {
    foo: 'bar'
  }
};

transport.sendMail(mail, function (err, info) {
  if (err) {
    console.error(err);
  } else {
    console.log(info);
  }
});

Use attachments

References to nodemailer attachments docs and Postmark attachments docs

'use strict';

const nodemailer = require('nodemailer');
const postmarkTransport = require('nodemailer-postmark-transport');
const transport = nodemailer.createTransport(postmarkTransport({
  auth: {
    apiKey: 'key'
  }
}));
const mail = {
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello',
  text: 'Hello, This email contains attachments',
  html: '<h1>Hello, This email contains attachments</h1>',
  attachments: [
    {
      path: 'data:text/plain;base64,aGVsbG8gd29ybGQ='
    }
  ]
};

transport.sendMail(mail, function (err, info) {
  if (err) {
    console.error(err);
  } else {
    console.log(info);
  }
});

Using Postmark API options

transport.sendMail({
  postmarkOptions: {

  }
}, /* ... */);

About

Postmark transport for Nodemailer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%