最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Nodemailer connection timeout error - Stack Overflow

programmeradmin1浏览0评论

I am using nodemailer module to send mail from my nodejs application. I am getting Error: connect ETIMEDOUT xxx.xxx.xx.xxx:465. Can any one help me in solving this. Here I am pasting my code.

var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
    user: '[email protected]',
    pass: 'my_gmail_password'
}
});

console.log('created');
transporter.sendMail({
from: '[email protected]',
  to: '[email protected]',
  subject: 'hello world!',
  text: 'hello world!'
});

I am using nodemailer module to send mail from my nodejs application. I am getting Error: connect ETIMEDOUT xxx.xxx.xx.xxx:465. Can any one help me in solving this. Here I am pasting my code.

var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
    user: '[email protected]',
    pass: 'my_gmail_password'
}
});

console.log('created');
transporter.sendMail({
from: '[email protected]',
  to: '[email protected]',
  subject: 'hello world!',
  text: 'hello world!'
});
Share Improve this question asked Feb 22, 2017 at 9:24 naik3naik3 3092 gold badges8 silver badges22 bronze badges
Add a ment  | 

10 Answers 10

Reset to default 4

This may be firewall problem. I faced similar problem in Ubuntu (Digital Ocean server). Tried to fix the issue for 3 days, tried using auth2 also, tried with inactive firewall using ufw inactive mand, but no luck. Finally I checked Digital Ocean admin panel and created firewall for the droplet. Problem solved by enabling TCP inbound and outbound in firewall settings.

Have you looked at this answer.

It turns out that in order for Google to authorize a third party server to access your account via SMTP now, you have to enable “Less Secure Apps” on your gmail account, if you want to use username/password (more info here).

So you have two option:

  • use OAuth

  • make your account less secure

I'm not sure if should be posting this answer but I've faced the same problem while using GMAIL and the reason behind the error for me was being connected to a vpn. I disabled it and now it works.

I'm using an application password

open port inbound outbound rule 587 or others, whichever you are using on server aws/google etc.

// Create a SMTP transport object
var transport = nodemailer.createTransport("SMTP", {
    service: 'Hotmail',
    auth: {
        user: "username",
        pass: "paasweord"
    }
});

console.log('SMTP Configured');

// Message object
  var message = {

  // sender info
  from: '[email protected]',

   // Comma separated list of recipients
  to: req.query.to //'[email protected]',

   // Subject of the message
  subject:req.query.subject //'Nodemailer is unicode friendly ✔', 

  // plaintext body
   text: req.query.text //'Hello to myself!',

  // HTML body
  /*  html:'<p><b>Hello</b> to myself <img src="cid:note@node"/></p>'+
     '<p>Here\'s a nyan cat for you as an embedded attachment:<br/></p>'*/
  };

  console.log('Sending Mail');
  transport.sendMail(message, function(error){
  if(error){
  console.log('Error occured');
  console.log(error.message);
  return;
  }
   console.log('Message sent successfully!');


//transport.close(); // close the connection pool
  });

I experienced this same issue today, found this documentation...

https://nodemailer./usage/using-gmail/

Had to do a capcha process from the server, by visiting a url while logged into gmail.

Hopefully it helps others.

Besides the already mentioned reference to the information at https://nodemailer./usage/using-gmail/, in my case the Internet Router (Speedport W724V) was still a problem. This keeps a list of all allowed SMTP servers. After I had extended the list accordingly, it worked perfectly. I had to do the same with smtp.ethereal.email.

I was using Linode and after researching a lot, I came across this munity post (https://www.linode./munity/questions/19082/i-just-created-my-first-linode-and-i-cant-send-emails-why). By default, they block the ports even if I set up the firewalls. So, I created a ticket and they resolved the issue

发布评论

评论列表(0)

  1. 暂无评论