EHOSTUNREACH error with nodemailer

18.1k Views Asked by At

I'm having an issue with nodemailer and would appreciate your help.

I am trying to send mail through nodemailer on node.js. EHOSTUNREACH error keeps popping up.I tried with two different services however, I keep getting the same error. My error log looks like

{ [Error: connect EHOSTUNREACH 65.55.163.152:587]
  code: 'EHOSTUNREACH',
  errno: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '65.55.163.152',
  port: 587,
  stage: 'init' }

The code that I'm using in my application is:

var smtpTransport = nodemailer.createTransport("SMTP",{
service: "hotmail",
auth: {
user: "[email protected]",
pass: "password"
}
}); 




api.post('/send',function(req,res){
    var mailOptions={
        from:'[email protected]',
        to : req.body.to,
        subject : req.body.subject,
        text1 : req.body.text1
    }
    console.log(mailOptions);
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
            res.end("error");
        }
        else{
            console.log("Message sent: " + response.message);
            res.end("sent");
        }
    });
})  

I am fairly new to node and fail to understand the reason for this occurance. Any help on the matter is solicited.

1

There are 1 best solutions below

0
mscdex On

EHOSTUNREACH means that no route to that particular host could be found. You may want to check your network setup (your OS's routing table in particular).