58 lines
1.4 KiB
JavaScript
Raw Normal View History

'use strict';
/**
* Module dependencies
*/
// Public node modules.
const _ = require('lodash');
const sendmail = require('sendmail')({
silent: true
});
/* eslint-disable no-unused-vars */
module.exports = {
provider: 'sendmail',
name: 'Sendmail',
auth: {
sendmail_default_from: {
label: 'Sendmail Default From',
type: 'text'
},
sendmail_default_replyto: {
label: 'Sendmail Default Reply-To',
type: 'text'
}
},
init: (config) => {
return {
send: (options, cb) => {
return new Promise((resolve, reject) => {
// Default values.
options = _.isObject(options) ? options : {};
options.from = options.from || config.sendmail_default_from;
options.replyTo = options.replyTo || config.sendmail_default_replyto;
options.text = options.text || options.html;
options.html = options.html || options.text;
sendmail({
from: options.from,
to: options.to,
replyTo: options.replyTo,
subject: options.subject,
text: options.text,
2019-10-03 13:42:32 +02:00
html: options.html,
attachments: options.attachments
}, function (err) {
if (err) {
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
} else {
resolve();
}
2019-10-03 13:42:32 +02:00
});
});
}
};
}
};