Shouldn't be an issue with running from a local server.
It looks like you are using direct transport, which is described in the docs as:
...not reliable as outgoing port 25 used is often blocked by default. Additionally mail sent from dynamic addresses is often flagged as spam. You should really consider using a SMTP provider.
One solution is to define a SMTP transport:
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'sender@gmail.com',
pass: 'password'
}
});
There are other solutions here, such as using a Transport Plugin.
Regardless, it is tough to diagnose your issue when you are not adding callbacks to your sendMail function. When you send mail, do it like this, and then you can check the console to see what the error may be:
transporter.sendMail({
from: contact.email,
to: to,
subject: contact.subject,
text: contact.message
}, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});