在我的 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 不允许端口 25 上的出站连接 https://cloud.google.com/compute/docs/tutorials/sending-mail/。如果 1&1 支持非标准端口上的入站电子邮件,那么您可以使用它。上面的页面提供了使用 Sendgrid、Mailgun 和 Mailjet(使用非标准端口)发送电子邮件的指南。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)