38 lines
894 B
JavaScript
Raw Normal View History

2018-07-24 10:28:44 +03:00
'use strict';
const nodeSES = require('node-ses');
module.exports = {
init: (providerOptions = {}, settings = {}) => {
var client = nodeSES.createClient({ ...providerOptions });
2018-07-24 10:28:44 +03:00
return {
send: options => {
2018-07-24 10:28:44 +03:00
return new Promise((resolve, reject) => {
const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
2018-07-24 10:28:44 +03:00
let msg = {
from: from || settings.defaultFrom,
to,
cc,
bcc,
replyTo: replyTo || settings.defaultReplyTo,
subject,
text,
html,
...rest,
2018-07-24 10:28:44 +03:00
};
client.sendEmail(msg, function(err) {
2018-07-24 10:28:44 +03:00
if (err) {
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
} else {
resolve();
}
});
});
},
2018-07-24 10:28:44 +03:00
};
},
2018-07-24 10:28:44 +03:00
};