SMTP 服务器需要安全连接或客户端未通过身份验证。使用 c# webapplication 发送 outlook 邮件时出错

The SMTP server requires a secure connection or the client was not authenticated. Error while sending outlook mail using c# webapplication

我不确定 mailServer 应该用于 microsoft.com 邮件。
这是我的代码:

string toemail = "v-***@microsoft.com";
string subject =  "Testing Mail";
string mailBody = "<p>Hi..<br />This is testing email<br />Regards,<br />Nikita</p>";
// string senderEmail = System.Configuration.ConfigurationManager.AppSettings["SenderEmail"].ToString(); 
string senderEmail = "v-****@microsoft.com";
string sendPwd = System.Configuration.ConfigurationManager.AppSettings["SenderPwd"].ToString();
SmtpClient smtpCl = new SmtpClient("smtp-mail.outlook.com", 25);
                smtpCl.EnableSsl = true;
smtpCl.Timeout = 1000000;
smtpCl.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpCl.UseDefaultCredentials = false;
smtpCl.Credentials = new NetworkCredential(senderEmail, sendPwd);

MailMessage mailMessage = new MailMessage(senderEmail, toemail, subject, mailBody);

mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = UTF8Encoding.UTF8;
smtpCl.Send(mailMessage);

您应该使用端口 587,请参阅 POP and IMAP email settings for Outlook

SmtpClient smtpCl = new SmtpClient("smtp-mail.outlook.com", 587);