【问题标题】:unable to send mail from linux server using nodemailer无法使用 nodemailer 从 linux 服务器发送邮件
【发布时间】:2018-04-13 22:20:40
【问题描述】:

我正在尝试在用户注册后发送邮件。 我为此使用nodemailer。 我的代码看起来像这样-

 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);
  };

当我在我的窗口机器上的本地主机上使用它时,邮件运行正常,但是当我在我的远程服务器上使用它时,它是一个 linux 服务器。 我收到以下错误:

错误--- {错误:连接超时 在 SMTPConnection._formatError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19) 在 SMTPConnection._onError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:530:20) 在 Timeout._connectionTimeout.setTimeout (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:248:18) 在 ontimeout (timers.js:471:11) 在 tryOnTimeout (timers.js:306:5) 在 Timer.listOnTimeout (timers.js:266:5) 代码:'ETIMEDOUT',命令:'CONN'} info----- undefined

【问题讨论】:

    标签: node.js linux


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-01
      • 1970-01-01
      • 2017-01-05
      • 1970-01-01
      • 2019-11-26
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多