I have a C# .Net code that sends email through gmail when I am using one of the gmail accounts like below:
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("test@example.com","Test12345");
smtp.Timeout = 9000;
smtp.Send(MMsg);
The email that is working is the one I was using in past but we need to change this email to the new one. Any of the new email credentials is not working. It gives me the error as:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Line 120: smtp.Credentials = new NetworkCredential("test@example.com", "Test12345");
Line 121: smtp.Timeout = 9000;
Line 122: smtp.Send(MMsg);
Any idea what I am missing? How can I make other new email through application to work?
Update: I had to turn on "Access for less secure Apps" on google site: https://www.google.com/settings/security/lesssecureapps to make it work.