【发布时间】:2020-05-06 06:25:28
【问题描述】:
我正在使用 office365 发送邮件,如下代码
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("*******", "*********"));
msg.From = new MailAddress("******", "*******");
msg.Subject = "This is a Test Mail";
msg.Body = "This is a test message using Exchange OnLine";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("******", "********");
client.Port = 587; // You can use Port 25 if 587 is blocked (mine is!)
client.Host = "d*******.mail.protection.outlook.com";//"smtp.office365.com";//
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Send(msg);
当我使用smtp.office365.com 时,我遇到了以下问题
SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.7.57 SMTP;客户不是 在 MAIL FROM 期间经过身份验证以发送匿名邮件 [BM1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM]
如果我使用d**********.mail.protection.outlook.com,那么我得到了
无法从传输连接读取数据:net_io_connectionclosed。
【问题讨论】:
标签: office365