mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 21:09:39 +00:00

- Hooks registry - D&P CT migrations - i18N CT migrations - Umzug with js / sql migrations - Eslint updates
45 lines
859 B
JavaScript
45 lines
859 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Module dependencies
|
|
*/
|
|
|
|
const _ = require('lodash');
|
|
const nodemailer = require('nodemailer');
|
|
|
|
const emailFields = [
|
|
'from',
|
|
'replyTo',
|
|
'to',
|
|
'cc',
|
|
'bcc',
|
|
'subject',
|
|
'text',
|
|
'html',
|
|
'attachments',
|
|
];
|
|
|
|
module.exports = {
|
|
provider: 'nodemailer',
|
|
name: 'Nodemailer',
|
|
|
|
init(providerOptions = {}, settings = {}) {
|
|
const transporter = nodemailer.createTransport(providerOptions);
|
|
|
|
return {
|
|
send(options) {
|
|
// Default values.
|
|
const emailOptions = {
|
|
..._.pick(options, emailFields),
|
|
from: options.from || settings.defaultFrom,
|
|
replyTo: options.replyTo || settings.defaultReplyTo,
|
|
text: options.text || options.html,
|
|
html: options.html || options.text,
|
|
};
|
|
|
|
return transporter.sendMail(emailOptions);
|
|
},
|
|
};
|
|
},
|
|
};
|