X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Futils%2Fmailer.js;h=b0a0bacef90f69ac18860f409c58342cdbab1f7b;hb=cafe016679ee9c14bf7bf0a37104ade7f74aff89;hp=9a42a1742a059cf843bd2a2911e32abbb3878df9;hpb=dac395887d96e2d642b209c6db6aaacc3ffacb34;p=vchess.git diff --git a/server/utils/mailer.js b/server/utils/mailer.js index 9a42a174..b0a0bace 100644 --- a/server/utils/mailer.js +++ b/server/utils/mailer.js @@ -8,11 +8,18 @@ module.exports = function(from, to, subject, body, cb) { console.log("New mail: from " + from + " / to " + to); console.log("Subject: " + subject); - let msgText = body.split('\\n'); - msgText.forEach(msg => { console.log(msg); }); - return cb(); + console.log(body); + if (!cb) + cb = (err) => { if (err) console.log(err); } + cb(); + return; } + // Production-only code from here: + + if (!cb) + cb = () => {}; //default: do nothing (TODO: log somewhere) + // Create reusable transporter object using the default SMTP transport const transporter = nodemailer.createTransport({ host: params.mail.host, @@ -35,10 +42,8 @@ module.exports = function(from, to, subject, body, cb) // Send mail with the defined transport object transporter.sendMail(mailOptions, (error, info) => { - if (!!error) - return cb(error); // Ignore info. Option: //console.log('Message sent: %s', info.messageId); - return cb(); + cb(error); }); }