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

Commit 5f24ffa

Browse files
committed
upgrade mailgun driver
1 parent d1c8437 commit 5f24ffa

File tree

3 files changed

+143
-571
lines changed

3 files changed

+143
-571
lines changed

index.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11

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

4-
var SimpleMailgunAdapter = mailgunOptions => {
4+
const SimpleMailgunAdapter = mailgunOptions => {
55
if (!mailgunOptions || !mailgunOptions.apiKey || !mailgunOptions.domain || !mailgunOptions.fromAddress) {
66
throw 'SimpleMailgunAdapter requires an API Key, domain, and fromAddress.';
77
}
8-
var mailgun = Mailgun(mailgunOptions);
9-
10-
var sendMail = mail => {
11-
var data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
8+
const mailgunClient = Mailgun.client({
9+
username: 'api',
10+
key: mailgunOptions.apiKey
11+
});
1212

13-
return new Promise((resolve, reject) => {
14-
mailgun.messages().send(data, (err, body) => {
15-
if (typeof err !== 'undefined') {
16-
reject(err);
17-
return;
18-
}
19-
resolve(body);
20-
});
21-
});
13+
const sendMail = mail => {
14+
const data = Object.assign({}, mail, { from: mailgunOptions.fromAddress });
15+
return mailgunClient.messages.create(mailgunOptions.domain, data);
2216
}
2317

2418
return Object.freeze({

0 commit comments

Comments
 (0)