mandrill-nodemailer-transport
Version:
Mandrill API and Nodemailer v4+. The plugin is very small, optimized and written in TypeScript
38 lines (37 loc) • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MandrillTransport = void 0;
const Requestly_1 = require("./services/Requestly");
const Mandrill_1 = require("./models/Mandrill");
class MandrillTransport {
constructor(options) {
this.options = options;
this.name = 'MandrillTransport';
this.version = 'N/A';
}
send(mail, done) {
setImmediate(() => {
mail.normalize((error, data) => {
if (error)
return done(error);
const mandrillData = Mandrill_1.Mandrill.buildData(data, this.options.apiKey);
Requestly_1.Requestly.postJSON({
protocol: 'https:',
hostname: 'mandrillapp.com',
path: '/api/1.0/messages/send.json'
}, mandrillData)
.then((mandrillResponse) => {
done(null, {
envelope: mail.message.getEnvelope(),
messageId: mail.message.messageId(),
message: mandrillData.message,
response: mandrillResponse
});
})
.catch(e => done(e));
});
});
}
}
exports.MandrillTransport = MandrillTransport;
exports.default = MandrillTransport;