這幾天發送郵件時突然會報一個錯
無法從傳輸連接中讀取數據: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