【发布时间】: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