Hi
I am getting below error - Message = "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at"
C#
Email.Body = BodyStr;
Email.BodyEncoding = Encoding.UTF8;
Email.IsBodyHtml = true;
Email.Priority = MailPriority.Normal;
SmtpClient sc = new SmtpClient(Result.SMTPHost, Convert.ToInt32(Result.SMTPPort));
sc.Credentials = new System.Net.NetworkCredential(Result.Email, "test");
sc.UseDefaultCredentials = false;
sc.EnableSsl = Convert.ToBoolean(Result.EnableSsl);
sc.Send(Email);Thanks

Vishal YelveRank #178 · 13.6K reputationPosted Oct 6, 2022, 9:45 AM EDT
Hi Ramco,
Please refer below link, hope this might help you.
https://www.aspsnippets.com/Articles/Send-email-using-Gmail-SMTP-Mail-Server-in-ASPNet.aspx
https://www.aspsnippets.com/Articles/GMAIL-Error-The-SMTP-server-requires-a-secure-connection-or-the-client-was-not-authenticated.aspx
Uttam KumarRank #1,076 · 1.8K reputationPosted Oct 7, 2022, 12:21 AM EDT
Google may block sign-in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.
Therefore, you have to enable Less Secure Sign-In (or Less secure app access) in your google account.
After signing into your Google account, go to:
https://www.google.com/settings/security/lesssecureapps
or
https://myaccount.google.com/lesssecureapps
In C#, you can use the following code:
using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress("[email protected]"); mail.To.Add("[email protected]"); mail.Subject = "Hello World"; mail.Body = "Hello"; mail.IsBodyHtml = true; mail.Attachments.Add(new Attachment("C:\\file.zip")); using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)) { smtp.Credentials = new NetworkCredential("[email protected]", "password"); smtp.EnableSsl = true; smtp.Send(mail); } }Vishal YelveRank #178 · 13.6K reputationPosted Oct 6, 2022, 8:35 AM EDT
Hi Ramco,
try this by setting this
ss.UseDefaultCredentials = true;Ramco RamcoRank #462 · 5.4K reputationPosted Oct 6, 2022, 9:02 AM EDT
Hi
Even then same error
Thanks
Vishal YelveRank #178 · 13.6K reputationPosted Oct 6, 2022, 9:35 AM EDT
Try this, hope this will work
sc.Credentials = new System.Net.NetworkCredential("[email protected]", "password"); sc.EnableSsl = true; sc.UseDefaultCredentials = false;Ramco RamcoRank #462 · 5.4K reputationPosted Oct 6, 2022, 9:42 AM EDT
Hi Vishal
Below is the code but still same problem , Even in Gmail i have set Less secure App Access = "On".
Email.Body = BodyStr; Email.BodyEncoding = Encoding.UTF8; Email.IsBodyHtml = true; Email.Priority = MailPriority.Normal; SmtpClient sc = new SmtpClient("smtp.gmail.com", 587); sc.Credentials = new System.Net.NetworkCredential("[email protected]", "test123@"); sc.EnableSsl = true; sc.UseDefaultCredentials = false; sc.Send(Email);Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Oct 7, 2022, 12:29 AM EDT
Hi Uttam
I tried but still same problem, Below is my code
Email.BodyEncoding = Encoding.UTF8; Email.IsBodyHtml = true; Email.Priority = MailPriority.Normal; SmtpClient sc = new SmtpClient("smtp.gmail.com", 587); sc.Credentials = new System.Net.NetworkCredential("[email protected]", "test123@"); sc.EnableSsl = true; sc.UseDefaultCredentials = false; sc.Send(Email);Thanks
Uday DodiyaRank #239 · 10.3K reputationPosted Oct 7, 2022, 1:47 AM EDT
Sometimes google blocks the third party access, so you have to enable Less-Secure Sign In