Akash Patel a00028636d
Fix #6377 ses email sending, pass required message key (#6378)
* fix email sending, pass required message key

fix regression pass required message key to node-ses & also pass altText

* fix email sending, pass required message key

fix regression pass required message key to node-ses & also pass altText

Signed-off-by: Akash P <aksdevac@gmail.com>
2020-05-28 11:56:13 +02:00

39 lines
982 B
JavaScript

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