1 const nodemailer
= require('nodemailer');
2 const params
= require("../config/parameters");
4 module
.exports = function(from, to
, subject
, body
, cb
)
6 // Create reusable transporter object using the default SMTP transport
7 const transporter
= nodemailer
.createTransport({
8 host: params
.mail
.host
,
9 port: params
.mail
.port
,
10 secure: params
.mail
.secure
,
12 user: params
.mail
.user
,
13 pass: params
.mail
.pass
17 // Setup email data with unicode symbols
19 from: from, //note: some SMTP serves might forbid this
25 // Avoid the actual sending in development mode
26 const env
= process
.env
.NODE_ENV
|| 'development';
27 if ('development' === env
)
29 console
.log("New mail: from " + from + " / to " + to
);
30 console
.log("Subject: " + subject
);
31 let msgText
= body
.split('\\n');
32 msgText
.forEach(msg
=> { console
.log(msg
); });
36 // Send mail with the defined transport object
37 transporter
.sendMail(mailOptions
, (error
, info
) => {
40 // Ignore info. Option:
41 //console.log('Message sent: %s', info.messageId);