find and solve || findandsolve.com
Please wait.....

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

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

First your make sure that Access less secure app is allowed.
Some time google may be block sign in attempts from some devies or apps so that do not uses modern security standards.
Since these apps and devices are easier to break into.blocking them helps keep your account safer.

Make sure after sign into google account  as given below

https://www.google.com/settings/security/lesssecureapps


or
https://myaccount.google.com/lesssecureapps

In C#, you can use the following code as given below


using (MailMessage mail = new MailMessage())
{
    mail.From = new MailAddress("<[email protected]>");
mail.To.Add("<received gmail>"); mail.Subject = "Hello find and solve"; mail.Body = "<h1>Hello</h1>"; mail.IsBodyHtml = true; mail.Attachments.Add(new Attachment("e:\\yourfile.zip")); using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)) { smtp.Credentials = new NetworkCredential("<[email protected]>", "<email password>");
smtp.EnableSsl = true; smtp.Send(mail); } }
OR

  1. Use smtp.gmail.com instead of smtp.google.com
  2. Use port 587
  3. Set client.UseDefaultCredentials = false; before setting credentials
  4. Turn on the Access for less secure apps
  5. Set client.EnableSsl = true;
Note:

Below is the very general thing that  always check first for such issues

client.UseDefaultCredentials = true;

Sundar  Neupane

Sundar Neupane

I like working on projects with a team that cares about creating beautiful and usable interfaces.

Comments



Report Response