这几天发送邮件时突然会报一个错
无法从传输连接中读取数据:net_io_connectionclosed。
因使用的是 smtp.office365.com
经过查询,发现了这个
Recently, we started rejecting a percentage of connections to smtp.office365.com that uses TLS1.0/1.1
for SMTP AUTH (complete disablement will start early 2022).
所以切换到TLS1.2就能够修复。
附上代码:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
参考:https://stackoverflow.com/questions/28362132/office-365-smtp-starts-firing-net-io-connectionclosed