繁体   English   中英

Nodemailer - SMTP 超时 - office365

[英]Nodemailer - SMTP Timeout - office365

我正在尝试使用带有 office365 邮件的 nodemailer 的 SMTP 连接。

当我尝试发送邮件时,它会引发此错误 -

错误:connect ETIMEDOUT xx.xxx.xxx.xxx:587 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14) errno: 'ETIMEDOUT', code: 'ECONNECTION', syscall: 'connect', address: 'xx.xxx.xxx.xxx',端口:587

这不是代理问题,因为我在网络之外尝试过,它也抛出了同样的错误。

`

var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
    host: 'smtp.office365.com',
    secure: false,
    auth: {
        user: "xxxxx@xxx.com",
        pass: "xxxxx"
    },
    tls: {
        ciphers: 'SSLv3'
    }
});
var message = {
    from: 'Sender Name <xxx@xxx.com>',
    to: '"Receiver Name" <xxx@xxx.com>',
    subject: 'Nodemailer',
    text: 'Hello to myself!'
};
transporter.sendMail(message, function(error, response) {
    if (error) {
        console.log('Error occured');
        res.end("<html><body><h1>error</h1></body></html>");
        console.log(error);
        return;
    } else {
        console.log(response);
        res.end("<html><body><h1>success</h1></body></html>");
        console.log('Message sent successfully!');
    }
});

`

我尝试过其他服务以及 Gmail,它也在网络内部和外部出现相同的错误。

您是否有可以阻止端口的本地防火墙或防病毒产品? 我的公司经常阻止计算机在常见的 SMTP 端口上建立出站连接,因为这是一个常见的多邮件病毒传播路径。 smtp.office365.com 从我知道能够启动出站 SMTP 流量的主机在端口 25 和 587 上进行响应。

[~]# nmap -p25,587 smtp.office365.com

Starting Nmap 7.60 ( https://nmap.org ) at 2018-12-04 10:39 EST
Nmap scan report for smtp.office365.com (40.97.170.178)
Host is up (0.027s latency).

PORT    STATE SERVICE
25/tcp  open  smtp
587/tcp open  submission

这可能有点晚了,但这对未来的其他人来说更是如此。

超时的常见原因是您必须启用 SMTP,如果使用 Mac,这可以通过PowerShell完成,然后查看此处 如果您使用的是 mac,则必须安装WSman,因为它没有附带 powershell。 在端口587上运行。 secure设置为false 然后确保您的配置电子邮件和postman authdata的电子邮件相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM