I have application built using angularjs and nodejs where the admin has to get a mail about the details form the contact us from of the application
I am using nodemailer for it but i not able to figure out how to send the details entered by the user coming from the request in the mail body am getting has req.body.name but excepted is the name of the user(eg:sam)
var nodemailer = require('nodemailer');
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail", // sets automatically host, port and connection security settings
auth: {
user: "[email protected]",
pass: "*****"
}
});
router.route('/sendmail')
.post(function(req,res){
console.log("!!!!!!!!!!!!!!!!1");
console.log(req.body);
smtpTransport.sendMail({ //email options
from: "[email protected]", // sender address. Must be the same as authenticated user if using Gmail.
to: "[email protected]", // receiver
subject: "UsersQuery", // subject
***html: "<b style='color: #006600'>UserQuery</b><p>name:req.body.name</p><p>name:req.body.email</p><p>name:req.body.message</p>"***
}, function(error, response){ //callback
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
smtpTransport.close(); // shut down the connection pool, no more messages. Comment this line out to continue sending emails.
});
res.send("done");
});