Pierre Noël 471d9ef89c move email settings from db to files
Signed-off-by: Pierre Noël <petersg83@gmail.com>
2020-05-14 16:56:14 +02:00

41 lines
915 B
JavaScript

'use strict';
/**
* Module dependencies
*/
// Public node modules.
const sendmail = require('sendmail')({
silent: true,
});
/* eslint-disable no-unused-vars */
module.exports = {
init: config => {
return {
send: options => {
return new Promise((resolve, reject) => {
sendmail(
{
from: options.from || config.defaultFrom,
to: options.to,
replyTo: options.replyTo || config.defaultReplyTo,
subject: options.subject,
text: options.text,
html: options.html,
attachments: options.attachments,
},
function(err) {
if (err) {
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
} else {
resolve();
}
}
);
});
},
};
},
};