This repository was archived by the owner on Apr 8, 2021. It is now read-only.
File tree 3 files changed +143
-571
lines changed
3 files changed +143
-571
lines changed Original file line number Diff line number Diff line change 1
1
2
- var Mailgun = require ( 'mailgun- js' ) ;
2
+ const Mailgun = require ( 'mailgun. js' ) ;
3
3
4
- var SimpleMailgunAdapter = mailgunOptions => {
4
+ const SimpleMailgunAdapter = mailgunOptions => {
5
5
if ( ! mailgunOptions || ! mailgunOptions . apiKey || ! mailgunOptions . domain || ! mailgunOptions . fromAddress ) {
6
6
throw 'SimpleMailgunAdapter requires an API Key, domain, and fromAddress.' ;
7
7
}
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
+ } ) ;
12
12
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 ) ;
22
16
}
23
17
24
18
return Object . freeze ( {
You can’t perform that action at this time.
0 commit comments