简体   繁体   English

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

I'm not sure about which mailServer should be using for microsoft.com mail.我不确定应该为 microsoft.com 邮件使用哪个mailServer
This is my code:这是我的代码:

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);

You should use port 587, see POP and IMAP email settings for Outlook .您应该使用端口 587,请参阅Outlook 的 POP 和 IMAP email 设置

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SMTP服务器需要安全连接,或者客户端未通过身份验证。 发送邮件异常 - The SMTP server requires a secure connection or the client was not authenticated. Exception on sending mail 邮件错误:SMTP服务器需要安全连接,或者客户端未通过身份验证。 服务器响应为:5.5.1需要身份验证 - Mail Error:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required c# SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应为:5.7.0 需要身份验证 - c# The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required C#“其他信息:SMTP服务器需要安全连接,或者客户端未经过身份验证。” - C# “Additional information: The SMTP server requires a secure connection or the client was not authenticated.” SMTP 服务器需要安全连接或客户端未通过身份验证。 如果上传到godaddy - The SMTP server requires a secure connection or the client was not authenticated. if uploading on godaddy SMTP服务器需要安全连接或客户端未经过身份验证。 - The SMTP server requires a secure connection or the client was not authenticated. SMTP服务器需要安全连接,或者客户端未通过身份验证。 - The SMTP server requires a secure connection or the client was not authenticated. SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应为:5.7.57 SMTP; Office 365 错误 - The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Office 365 error 出现错误:SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应为:5.7.57 SMTP - Getting error : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP 如何修复 GMail SMTP 错误:“SMTP 服务器需要安全连接或客户端未通过身份验证。” - How to fix GMail SMTP error: "The SMTP server requires a secure connection or the client was not authenticated."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM