标签:
问题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("test@ms.com", "1234567890");
MailMessage mm = new MailMessage("test@ms.com", "user1@ms.com", "test", "test");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
}
}
最后在配置TFS邮件通知设置的时候端口改用25,不选择SSL,顺利解决问题。
SmtpClient发送邮件超时的异常参考:
标签:
原文地址:http://www.cnblogs.com/wgscd/p/4479391.html