So I am writing some code to send me a email when someone visits my website. Here is the code I have
app.get("/", function(req, res, next) {
var mailOptions = {
from: 'removed for obvious reasons',
to: 'removed for obvious reasons',
subject: 'User visited',
text: 'A user has visited your site'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
console.log("User visited");
next();
}, function(req, res) {
res.sendFile( path.join( __dirname, "client-files", "index.html" ));
});
But when I visit my website then I get nothing. I don't get a email and nothing's printed out, I just get the web page. Does anyone know how to fix this?