2

I'm deploying my node express project with iis. I'm sending mail with node mailer. but I get the username and password from the config file. Is there any way I can get a username and password parametrically via iis user? I do not want the username and password to be visible. how can I do it?

        var transporter = nodemailer.createTransport({
            host: //config file host- local smtp,
            port: //config file port,
            logger:false,
            secure: false,
            auth: {
                user: //config file user,
                pass: //config file pass
            }
        });

        var mailOptions = {
            from: //config file user,
            to: //config file mailadress,
            subject: //config file subject
            html: //config file data
        };

        transporter.sendMail(mailOptions, function (error, info) {
            if (error) {
                console.log('Error while sending email' + error);
            } else {
                console.log('E-mail send to : ' + info.response);
            }
        });
zey
  • 177
  • 2
  • 15
  • you could try to remove the auth section from your code when creating an SMTP Transport message. refer this link:https://stackoverflow.com/questions/30915374/sending-mail-without-authentication-using-nodejs/43792994 – Jalpa Panchal Feb 16 '21 at 07:30
  • Thank you very much for your reply. I can't try it in my test environment, will it work on prod as follows? var transporter = nodemailer.createTransport({ host: config.mailhost, port: config.mailport, logger:false, secure: false }); – zey Feb 17 '21 at 08:02
  • you could try to use and check it is working or not. – Jalpa Panchal Feb 17 '21 at 09:56

0 Answers0