gpt4 book ai didi

node.js - 电子邮件未通过 1and1 smtp 主机 nodemailer caddy 发送

转载 作者:太空宇宙 更新时间:2023-11-03 23:00:41 26 4
gpt4 key购买 nike

在我的nodejs Express应用程序中,当新用户注册时,我使用nodemailer发送电子邮件,这是我的电子邮件配置,在我的config.json中:

 {
"senderEmail": "email",
"senderEmailPassword":"password",
"smtpPort":587,
"smtpHost":"smtp.1and1.com"
}

transporterOptions如下:

var transporterOptions = {
host: config.smtpHost,
port: config.smtpPort,
auth: {
user: config.senderEmail,
pass: config.senderEmailPassword
},
secure:false
};

现在在我的本地(开发)环境中,它能够从 1and1 主机发送电子邮件,但问题是当我使我的应用程序上线(生产)时,它无法发送电子邮件,错误如下: 错误:连接超时堆栈跟踪如下:

{ Error: Connection timeout
at SMTPConnection._formatError (/home/*/*/*/node_modules/nodemailer/lib/smtp-connection/index.js:591:19)
at SMTPConnection._onError (/home/*/*/*/node_modules/nodemailer/lib/smtp-connection/index.js:564:20)
at Timeout._connectionTimeout.setTimeout (/home/*/*/*/node_modules/nodemailer/lib/smtp-connection/index.js:256:18)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'ETIMEDOUT', command: 'CONN' }

服务器配置是通过caddy完成的。预先感谢您。

最佳答案

GCE does not allow outbound connections on port 25 。如果 1&1 支持非标准端口上的入站电子邮件,那么您可以使用它。上面的页面提供了使用 Sendgrid、Mailgun 和 Mailjet(使用非标准端口)发送电子邮件的指南。

关于node.js - 电子邮件未通过 1and1 smtp 主机 nodemailer caddy 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48993298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com