A Postmark transport for Nodemailer.
- Node.js 4+
Note: If you node version is less than 4 should use nodemailer-postmark-transport@1.2.0
npm install nodemailer-postmark-transport
'use strict';
const nodemailer = require('nodemailer');
const postmarkTransport = require('nodemailer-postmark-transport');
const transport = nodemailer.createTransport(postmarkTransport({
auth: {
apiKey: 'key'
}
}));
const mail = {
from: 'john.doe@example.org',
to: 'jane.doe@example.org',
subject: 'Hello',
text: 'Hello',
html: '<h1>Hello</h1>'
};
transport.sendMail(mail, function (err, info) {
if (err) {
console.error(err);
} else {
console.log(info);
}
});
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: 'john.doe@example.org',
to: 'jane.doe@example.org',
templateId: 1234,
templateModel: {
foo: 'bar'
}
};
transport.sendMail(mail, function (err, info) {
if (err) {
console.error(err);
} else {
console.log(info);
}
});
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: 'john.doe@example.org',
to: 'jane.doe@example.org',
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);
}
});
transport.sendMail({
postmarkOptions: {
}
}, /* ... */);