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
);
13 cb
= (err
) => { if (!!err
) console
.log(err
); }
17 cb
= () => {}; //default: do nothing (TODO: log somewhere)
19 // Create reusable transporter object using the default SMTP transport
20 const transporter
= nodemailer
.createTransport({
21 host: params
.mail
.host
,
22 port: params
.mail
.port
,
23 secure: params
.mail
.secure
,
25 user: params
.mail
.user
,
26 pass: params
.mail
.pass
30 // Setup email data with unicode symbols
32 from: params
.mail
.noreply
,
39 // Send mail with the defined transport object
40 transporter
.sendMail(mailOptions
, (error
, info
) => {
43 // Ignore info. Option:
44 //console.log('Message sent: %s', info.messageId);