X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Futils%2Fmailer.js;h=96fa75cfee755ff3f77f9b6095593f8b6dea4031;hb=2bb4666e276e837add0958554a11b38f7f4d9357;hp=60cc9f26d66974018fc726c90d3888f89bdc069f;hpb=a749972cf93fd021dda11389753ae4985ff61b42;p=vchess.git diff --git a/server/utils/mailer.js b/server/utils/mailer.js index 60cc9f26..96fa75cf 100644 --- a/server/utils/mailer.js +++ b/server/utils/mailer.js @@ -1,20 +1,21 @@ const nodemailer = require('nodemailer'); const params = require("../config/parameters"); -module.exports = function(from, to, subject, body, cb) -{ +module.exports = function(from, to, subject, body, cb) { // Avoid the actual sending in development mode - if (params.env === 'development') - { + if (params.env === 'development') { console.log("New mail: from " + from + " / to " + to); console.log("Subject: " + subject); console.log(body); - if (!cb) - cb = (err) => { if (!!err) console.log(err); } - return cb(); + if (!cb) cb = (err) => { if (err) console.log(err); } + cb(); + return; } - else if (!cb) - cb = () => {}; //default: do nothing (TODO: log somewhere) + + // Production-only code from here: + + // Default: do nothing (TODO: log somewhere) + if (!cb) cb = () => {}; // Create reusable transporter object using the default SMTP transport const transporter = nodemailer.createTransport({ @@ -38,10 +39,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); }); -} +};