1 const nodemailer
= require('nodemailer');
2 const params
= require("../config/parameters");
4 module
.exports = function(from, to
, subject
, body
, cb
)
6 // Avoid the actual sending in development mode
7 if (params
.env
=== 'development')
9 console
.log("New mail: from " + from + " / to " + to
);
10 console
.log("Subject: " + subject
);
11 let msgText
= body
.split('\\n');
12 msgText
.forEach(msg
=> { console
.log(msg
); });
14 cb
= (err
) => { if (!!err
) console
.log(err
); }
18 cb
= () => {}; //default: do nothing (TODO: log somewhere)
20 // Create reusable transporter object using the default SMTP transport
21 const transporter
= nodemailer
.createTransport({
22 host: params
.mail
.host
,
23 port: params
.mail
.port
,
24 secure: params
.mail
.secure
,
26 user: params
.mail
.user
,
27 pass: params
.mail
.pass
31 // Setup email data with unicode symbols
33 from: params
.mail
.noreply
,
40 // Send mail with the defined transport object
41 transporter
.sendMail(mailOptions
, (error
, info
) => {
44 // Ignore info. Option:
45 //console.log('Message sent: %s', info.messageId);