c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

Solved-The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

| | CSharp , Networking

I got this following error “The SMTP server requires a secure connection or the client was not authenticated. The server response was:5.5.1 authentication Required” while attempting to send mail using asp.net c# (i.e Google authentication required).

Solution to gmail server error:

Case 1:Please enter the correct password!. Otherwise,It may happen SMTP server error, due to the invalid password.

Case 2: Google may block the sign in attempt due modern security standards. You need to enable the following features. Login into your google account and go to:

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

If you want to use, turn on the less secure access.

c# send mail coding, 

using (MailMessage mail = new MailMessage())
            {
                mail.From = new MailAddress("EMAILID@gmail.com"); //secureserver email settings 
                mail.To.Add("somebody@domain.com");  //sender emailID
                mail.Subject = "Greetings";
                mail.Body = "<h1>Welcome User</h1>";
                mail.IsBodyHtml = true;
                mail.Attachments.Add(new Attachment("C:\\book1.zip"));
 
                using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                {
                    smtp.Credentials = new System.Net.NetworkCredential("EMAILID@gmail.com", "password"); //secureserver settings 
                    smtp.EnableSsl = true;
                    smtp.Send(mail);
                } 

            }