[英]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:现在您可以管理应用程序密码:
change the email password in your app , and try to send emails在您的应用程序中更改电子邮件密码,并尝试发送电子邮件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.