问题System.Net.Mail下的SmtpClient来发送邮件,而System.Net.Mail only仅支持Explicit SSL
不要465端口,用25,不用EnableSsl = true;
{
static void Main(string[] args)
{
SmtpClient client = new SmtpClient();
client.Host = "smtp.exmail.qq.com";
client.Port = 25;
// client.Port = 465;
// client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "1234567890");
MailMessage mm = new MailMessage("[email protected]", "[email protected]", "test", "test");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
}
}
最后在配置TFS邮件通知设置的时候端口改用25,不选择SSL,顺利解决问题。
SmtpClient发送邮件超时的异常参考: