2018-07-24 10:28:44 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const nodeSES = require('node-ses');
|
2020-05-15 17:15:24 +02:00
|
|
|
const { removeUndefined } = require('strapi-utils');
|
2018-07-24 10:28:44 +03:00
|
|
|
|
|
|
|
module.exports = {
|
2020-05-15 15:05:35 +02:00
|
|
|
init: (providerOptions = {}, settings = {}) => {
|
|
|
|
var client = nodeSES.createClient({ ...providerOptions });
|
2018-07-24 10:28:44 +03:00
|
|
|
|
|
|
|
return {
|
2020-03-21 02:02:47 +13:00
|
|
|
send: options => {
|
2018-07-24 10:28:44 +03:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-05-15 15:05:35 +02:00
|
|
|
const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
|
2018-07-24 10:28:44 +03:00
|
|
|
|
|
|
|
let msg = {
|
2020-05-15 15:05:35 +02:00
|
|
|
from: from || settings.defaultFrom,
|
|
|
|
to,
|
|
|
|
cc,
|
|
|
|
bcc,
|
|
|
|
replyTo: replyTo || settings.defaultReplyTo,
|
|
|
|
subject,
|
2020-05-28 15:26:13 +05:30
|
|
|
altText: text,
|
|
|
|
message: html,
|
2020-05-15 15:05:35 +02:00
|
|
|
...rest,
|
2018-07-24 10:28:44 +03:00
|
|
|
};
|
|
|
|
|
2020-05-15 17:15:24 +02:00
|
|
|
client.sendEmail(removeUndefined(msg), function(err) {
|
2018-07-24 10:28:44 +03:00
|
|
|
if (err) {
|
2020-06-09 12:11:25 +02:00
|
|
|
reject(err);
|
2018-07-24 10:28:44 +03:00
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2019-07-02 15:09:59 +02:00
|
|
|
},
|
2018-07-24 10:28:44 +03:00
|
|
|
};
|
2019-07-02 15:09:59 +02:00
|
|
|
},
|
2018-07-24 10:28:44 +03:00
|
|
|
};
|