简体   繁体   English

如何解决谷歌邮件错误“SMTP 服务器需要安全连接或客户端未通过身份验证”?

[英]How to resolve a google mail error "The SMTP server requires secure connection or the client was not authenticated"?

MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("sendemail@gmail.com");
mailMessage.To.Add("receiveemail@mydomain.com");
mailMessage.Subject = "New Enquiry" ;

mailMessage.Body = "<b>Sender Name : </b>" + txt_name.Text + "<br/>"
    + "<b>Contact Number : </b>" + txt_number.Text + "<br/>"
    + "<b>Sender Email : </b>" + txt_email.Text + "<br/>"
    + "<b>Details : </b>" + txt_message.Text;
mailMessage.IsBodyHtml = true;


SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = 
    new System.Net.NetworkCredential("sendemail@gmail.com", "Password");
smtpClient.Send(mailMessage);

Response.Write("<Script>alert('Thanks for contact us,our team will be contact you as soon as possible')</Script>");

txt_name.Text = "";
txt_email.Text = "";
txt_number.Text = "";
txt_message.Text = "";

This is my ASP.NET C# code for sending emails through the website's contact us page.这是我的 ASP.NET C# 代码,用于通过网站的联系我们页面发送电子邮件。 But Google has discontinued the less secure app access option as of May 30, 2022 due to security reasons.但出于安全原因,谷歌已于 2022 年 5 月 30 日停止使用不太安全的应用访问选项。 So now I'm not able to send emails using the above code.所以现在我无法使用上面的代码发送电子邮件。

Less Secure app access snapshot:不太安全的应用访问快照:

不太安全的应用访问快照

How can I deal with this so I can send email again?我该如何处理这个问题,以便我可以再次发送电子邮件?

https://support.google.com/accounts/answer/6010255 https://support.google.com/accounts/answer/6010255

from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.自 2022 年 5 月 30 日起,Google 不再支持使用第三方应用或设备,这些应用或设备要求您仅使用您的用户名和密码登录您的 Google 帐户。

Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers.重要提示:此截止日期不适用于 Google Workspace 或 Google Cloud Identity 客户。 The enforcement date for these customers will be announced on the Workspace blog at a later date.这些客户的执行日期将在稍后的 Workspace 博客上公布。

Now you can manage Apps password:现在您可以管理应用程序密码:

  1. Go to Gmail account settings , and click on security tab转到 Gmail 帐户设置,然后单击安全选项卡
  2. add 2 step verification (if you don't have)添加两步验证(如果您没有)
  3. click on "App Password"点击“应用密码”
  4. select application device or add new one选择应用设备或添加新设备
  5. you will get new password to use in your app您将获得新密码以在您的应用程序中使用

change the email password in your app , and try to send emails在您的应用程序中更改电子邮件密码,并尝试发送电子邮件

暂无
暂无

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

相关问题 邮件错误: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 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 - Error 如何修复 GMail SMTP 错误:“SMTP 服务器需要安全连接或客户端未通过身份验证。” - How to fix GMail SMTP error: "The SMTP server requires a secure connection or the client was not authenticated." 无法在服务器上发送邮件。 获取异常 SMTP 服务器需要安全连接或客户端未通过身份验证 - Not able to send mail on server. Getting exception The SMTP server requires a secure connection or the client was not authenticated 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 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 System.Net.Mail.SmtpException:SMTP 服务器需要安全连接或客户端未通过身份验证 - System.Net.Mail.SmtpException: 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. Exception on sending mail
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM