Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

Commit

Permalink
upgrade mailgun driver
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza committed Apr 3, 2021
1 parent d1c8437 commit 5f24ffa
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 571 deletions.
24 changes: 9 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@

var Mailgun = require('mailgun-js');
const Mailgun = require('mailgun.js');

var SimpleMailgunAdapter = mailgunOptions => {
const SimpleMailgunAdapter = mailgunOptions => {
if (!mailgunOptions || !mailgunOptions.apiKey || !mailgunOptions.domain || !mailgunOptions.fromAddress) {
throw 'SimpleMailgunAdapter requires an API Key, domain, and fromAddress.';
}
var mailgun = Mailgun(mailgunOptions);

var sendMail = mail => {
var data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
const mailgunClient = Mailgun.client({
username: 'api',
key: mailgunOptions.apiKey
});

return new Promise((resolve, reject) => {
mailgun.messages().send(data, (err, body) => {
if (typeof err !== 'undefined') {
reject(err);
return;
}
resolve(body);
});
});
const sendMail = mail => {
const data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
return mailgunClient.messages.create(mailgunOptions.domain, data);
}

return Object.freeze({
Expand Down
Loading

0 comments on commit 5f24ffa

Please sign in to comment.