I know this may sound like a duplicate but I HAVE TRIED EVERYTHING my code is below
MailMessage mail = new MailMessage("XXXXXXXXX@gmail.com", "XXXXXXXX@gmail.comm");
SmtpClient client = new SmtpClient("smtp.gmail.com",587);
client.Credentials = new NetworkCredential("XXXXXXX@gmail.com", "yyyyyyyYYYYY");
client.EnableSsl = true;
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
client.Send(mail);
The error happens on this line of code:
client.Send(mail);
Error code is 5.5.1. I also tried turning allow less secure apps ON