[英]Nodemailer - SMTP Timeout - office365
I am trying to use SMTP connection with nodemailer with office365 mail.我正在尝试使用带有 office365 邮件的 nodemailer 的 SMTP 连接。
When I try to send mail, it throws up this error -当我尝试发送邮件时,它会引发此错误 -
Error: 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', port: 587错误: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
It is not a proxy issue, since I tried outside of the network and it throws up the same error as well.这不是代理问题,因为我在网络之外尝试过,它也抛出了同样的错误。
` `
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!');
}
});
` `
I tried with other services as well like Gmail, it also gives the same error inside and outside the network.我尝试过其他服务以及 Gmail,它也在网络内部和外部出现相同的错误。
Do you have a local firewall or anti-virus product that does port blocking?您是否有可以阻止端口的本地防火墙或防病毒产品? My company routinely blocks computers from making outbound connections on common SMTP ports because it was a common multi-mailer virus propagation path.我的公司经常阻止计算机在常见的 SMTP 端口上建立出站连接,因为这是一个常见的多邮件病毒传播路径。 smtp.office365.com responds on both port 25 and 587 from a host I know to be able to initiate outbound SMTP traffic. 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
this might be a bit late but this is more for anyone else in the future.这可能有点晚了,但这对未来的其他人来说更是如此。
Common cause for timeouts is you have to enable SMTP, if using a mac this can be done through PowerShell then look to here .超时的常见原因是您必须启用 SMTP,如果使用 Mac,这可以通过PowerShell完成,然后查看此处。 If youre on a mac, you'll have to install WSman because it doesnt come with powershell.如果您使用的是 mac,则必须安装WSman,因为它没有附带 powershell。 run on port 587
.在端口587
上运行。 set secure
to false
.将secure
设置为false
。 then make sure your config email and the email in your auth
and data
for postman
are the same.然后确保您的配置电子邮件和postman
auth
和data
的电子邮件相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.