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
); });
16 // Create reusable transporter object using the default SMTP transport
17 const transporter
= nodemailer
.createTransport({
18 host: params
.mail
.host
,
19 port: params
.mail
.port
,
20 secure: params
.mail
.secure
,
22 user: params
.mail
.user
,
23 pass: params
.mail
.pass
27 // Setup email data with unicode symbols
29 from: from, //note: some SMTP serves might forbid this
35 // Send mail with the defined transport object
36 transporter
.sendMail(mailOptions
, (error
, info
) => {
39 // Ignore info. Option:
40 //console.log('Message sent: %s', info.messageId);