Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29935

nodemailer mail options from: field is always sending mail from the email used in the smtpTrans auth object

$
0
0

I am using nodemailer to do contact forms and mailing things.

But when I try to set the req.body.email as the from: email it just uses the authentication email instead. So all emails I receive are from: me@me.com to: me@me.com

instead of from: customer@them.com to: me@me.com

I'm pretty sure I'm doing it right

var mailOpts, smtpTrans;

  //Setup Nodemailer transport, I chose gmail. Create an routerlication-specific password to avoid problems.
  smtpTrans = nodemailer.createTransport({
      service: 'Gmail',
      auth: {
        user: "me@me.com",
        pass: "hey"
      }
  });
  //Mail options
    console.log(req.body.email);
  mailOpts = {
      from: req.body.email, //grab form data from the request body object
      to: 'me@me.com',
      subject: 'Stockist interest form',
      text: "Welcome to the My Leisure Stockists application process, we'd love to have you on board"+"\n Email: "+req.body.email
  };

  smtpTrans.sendMail(mailOpts, function (error, response) {

      if (error) {
        res.sendStatus(500);
      } else {
        res.sendStatus(200);
      };

  });

Viewing all articles
Browse latest Browse all 29935

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>