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.

Solved-The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required., someone asked me to explain?

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).

smtp authentication is 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.

secureserver net email settings

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);
                } 

            }

 

Post your comments / questions