【问题标题】:Connection timeout error when sending mail from Zohomail using Nodemailer使用 Nodemailer 从 Zohomail 发送邮件时出现连接超时错误
【发布时间】:2017-09-30 20:32:25
【问题描述】:

下面是我的 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' }

谁能帮帮我?

【问题讨论】:

    标签: node.js smtp nodemailer zoho cloud9


    【解决方案1】:

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

    更新

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

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

    【讨论】:

    • 尝试将端口更改为 2525,仍然收到相同的错误!
    • 你的云提供商是谁?
    • 我正在为此使用 Cloud9 在线 IDE。
    • 感谢您的提示。我搬到了 Sublime 并从我的 cmd 执行它,它工作了:) 非常感谢。
    猜你喜欢
    • 2020-02-10
    • 2016-06-18
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-09
    • 2019-03-01
    • 1970-01-01
    相关资源
    最近更新 更多