gpt4 book ai didi

node.js - 使用 Nodemailer 从 Zohomail 发送邮件时出现连接超时错误

转载 作者:搜寻专家 更新时间:2023-11-01 00:29:18 26 4
gpt4 key购买 nike

下面是我的 Node app.js 代码。使用这些设置,我收到连接超时错误。知道我在这里缺少什么吗?

var nodemailer = require("nodemailer");

var transporter = nodemailer.createTransport({
host: 'smtp.zoho.com',
port: 465,
secure: true, // use SSL
auth: {
user: '<myemail@example.com>',
pass: '<myemailpassword>'
}
});

var mailOptions = {
from: "<fromemail@example.com>",
to: "<toemail@example.com>",
subject: "Hello",
generateTextFromHTML: true,
html: { path: './tmpl.html' }
};

transporter.sendMail(mailOptions, function(error, response) {
if (error) {
console.log(error);
} else {
console.log(response);
}
transporter.close();
});

显示错误

{ Error: Connection timeout
at SMTPConnection._formatError (/home/ubuntu/workspace/mailapp/node_modules/nodemailer/lib/smtp-connection/index.js:557:19)
at SMTPConnection._onError (/home/ubuntu/workspace/mailapp/node_modules/nodemailer/lib/smtp-connection/index.js:530:20)
at Timeout._connectionTimeout.setTimeout (/home/ubuntu/workspace/mailapp/node_modules/nodemailer/lib/smtp-connection/index.js:248:18)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'ETIMEDOUT', command: 'CONN' }

谁能帮帮我?

最佳答案

一些云提供商禁用了 465 和 587 等端口,请尝试使用端口 2525 而不是 465。

更新

由于您为此使用 Cloud9,我发现他们已阻止来自其服务器的所有出站 smtp 调用。如果您仍然需要发送,则需要选择其他云提供商或使用他们推荐的服务之一。

https://community.c9.io/t/how-can-i-send-email-from-my-app/1262

关于node.js - 使用 Nodemailer 从 Zohomail 发送邮件时出现连接超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43752772/

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