简体   繁体   English

无法使用nodemailer从linux服务器发送邮件

[英]unable to send mail from linux server using nodemailer

i am trying to send mail after user gets registered.我正在尝试在用户注册后发送邮件。 I am using nodemailer for this.我正在为此使用 nodemailer。 my code for this look like this-我的代码看起来像这样-

 var transporter = nodemailer.createTransport({
  service:"Mailjet", // sets automatically host, port and connection security settings
    auth: {
    user:'******',
    pass:'*******'
  }
});
var mailOptions = {
  to:mailTo,
  from:'******',
  subject:'user registered',
  text:'welcome user'
};
transporter.sendMail(mailOptions, function(err, info) {
  if (err) {
    logger.debug('error in sending email ' + err);
  } else {
    logger.debug('Message sent: ' + info.response);
  };

Mail is going properly when i use this on my localhost on my window machine but when i use this on my remote server which is a linux server.当我在我的窗口机器上的本地主机上使用它时,邮件运行正常,但是当我在我的远程服务器(Linux 服务器)上使用它时。 I get the following error :我收到以下错误:

error--- { Error: Connection timeout at SMTPConnection._formatError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19) at SMTPConnection._onError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:530:20) at Timeout._connectionTimeout.setTimeout (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:248:18) at ontimeout (timers.js:471:11) at tryOnTimeout (timers.js:306:5) at Timer.listOnTimeout (timers.js:266:5) code: 'ETIMEDOUT', command: 'CONN' } info----- undefined错误--- { 错误:SMTPConnection._formatError 处的连接超时 (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19) at SMTPConnection._onError (/root /root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:530:20) at Timeout._connectionTimeout.setTimeout (/root/root/server/cq-code/node_modules/nodemailer/lib /smtp-connection/index.js:248:18) at ontimeout (timers.js:471:11) at tryOnTimeout (timers.js:306:5) at Timer.listOnTimeout (timers.js:266:5) 代码: 'ETIMEDOUT', command: 'CONN' } info----- 未定义

代码工作正常。问题出在服务器上,实际上用于 SMTP 的端口被数字海洋阻止了。所以我向他们提出了一个问题,在解除阻止该端口后,事情按预期进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM