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);
};
});