96fa75cfee755ff3f77f9b6095593f8b6dea4031
1 const nodemailer
= require('nodemailer');
2 const params
= require("../config/parameters");
4 module
.exports = function(from, to
, subject
, body
, cb
) {
5 // Avoid the actual sending in development mode
6 if (params
.env
=== 'development') {
7 console
.log("New mail: from " + from + " / to " + to
);
8 console
.log("Subject: " + subject
);
10 if (!cb
) cb
= (err
) => { if (err
) console
.log(err
); }
15 // Production-only code from here:
17 // Default: do nothing (TODO: log somewhere)
18 if (!cb
) cb
= () => {};
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
) => {
42 // Ignore info. Option:
43 //console.log('Message sent: %s', info.messageId);