I am getting error while sending email using C# console application .it was working perfectly before few but it started giving me the error below is my code
smtp.Host = "smtp.gmail.com";
smtp.Port = Convert.ToInt32(587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.ServicePoint.MaxIdleTime = 60;
smtp.Timeout = 20000;
smtp.Credentials = new NetworkCredential(UserName, Password);
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtp.Send(msg);
Error
I have also updated 'Allow Less Secure Apps' to On in google settings does anyone has any idea
I have fixed the issue by own. I have to give the AD service account proper permission to send SMTP as any from address