首页 文章

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

提问于
浏览
1

我试图在用户注册后发送邮件 . 我正在使用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._onError上的SMTPConnection._formatError(/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19)的连接超时(/ 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)attimeout(timers.js:471:11)在tryOnTimeout(timers.js:306:5)的Timer.listOnTimeout(timers.js:266:5)代码:'ETIMEDOUT',命令:'CONN'} info ----- undefined

1 回答

  • 1

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

相关问题