【问题标题】:Nodemailer connection Error only on serverNodemailer连接错误仅在服务器上
【发布时间】:2021-04-01 05:14:11
【问题描述】:

我正在使用 nodemailer 从 nodejs 项目发送邮件,并使用 godaddy 提供的 Outlook 服务进行邮件服务,并且它在我的本地服务器上工作正常,但是一旦我将我的项目转移到生产服务器,它就会给出如下所述的错误

收到错误

0|node  | {"message":"message - Connection timeout, stack trace - Error: Connection timeout\n    at SMTPConnection._formatError (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)\n    at SMTPConnection._onError (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)\n    at Timeout._connectionTimeout.setTimeout (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)\n    at ontimeout (timers.js:436:11)\n    at tryOnTimeout (timers.js:300:5)\n    at listOnTimeout (timers.js:263:5)\n    at Timer.processTimers (timers.js:223:10)","level":"error"}
0|node  | { Error: Connection timeout
0|node  |     at SMTPConnection._formatError (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
0|node  |     at SMTPConnection._onError (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)
0|node  |     at Timeout._connectionTimeout.setTimeout (/var/www/html/dev/project/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)
0|node  |     at ontimeout (timers.js:436:11)
0|node  |     at tryOnTimeout (timers.js:300:5)
0|node  |     at listOnTimeout (timers.js:263:5)
0|node  |     at Timer.processTimers (timers.js:223:10) code: 'ETIMEDOUT', command: 'CONN' }

使用的节点邮件配置

var smtpTransport = nodemailer.createTransport({
host: "smtp.office365.com",
secureConnection: true,
port: 587,
service: 'Godaddy',
debug: false,
auth: {
  user: USER_NAME,
  pass: PASSWORD
}

});

【问题讨论】:

  • 您尝试使用的生产服务器是什么?生产服务器上的端口是否为 SMTP 开放?
  • 是的端口已启用 SMTP
  • 把secure的值改成false试试。
  • 已经试过了,还是一样的问题
  • 您使用的服务器是什么?

标签: javascript node.js outlook smtp nodemailer


【解决方案1】:

注意:共享您的身份验证凭据是不安全的。

首先:去你的办公室并启用电子邮件应用程序访问

第二:启用安全属性意味着您启用了 TLS,因此请确保您通过此链接正确应用了 TLS https://nodemailer.com/smtp/

【讨论】:

  • 这不是实际的身份验证凭据;)对于 TLS,我也尝试过,但我不确定正确的配置 tls: {ciphers:'SSLv3'}, 是否需要其他任何东西
  • 尝试删除 secure 和 tls 属性并添加这个来代替 secureConnection: true,
猜你喜欢
  • 2020-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-12
  • 1970-01-01
  • 2019-10-08
  • 2017-04-29
  • 1970-01-01
相关资源
最近更新 更多