I want the from(sender email) part to be gotten from the input but it keeps giving me the same thing as the sender and receiver the same i.e it keeps showing the user as the sender and receiver.
app.post('/', (req,res) =>{
// console.log(req.body);
const transporter = nodemailer.createTransport(smtpTransport({
service:'Gmail',
// host: 'smtp.gmail.com',
secure:false,
auth: {
user: '[email protected]',
pass: 'password'
}
}))
const mailOptions = {
from: req.body.email,
to : "[email protected]",
subject: `${req.body.subject}`,
text : req.body.message
}
transporter.sendMail(mailOptions, (error, info) =>{
if(error){
console.log(error);
res.send('error');
}else{
console.log('Email sent' + info.response);
res.send('success');
}
})
})
app.listen(PORT, ()=> {
console.log(`server running on port: ${PORT}`);
})