Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.


i have also converted my gmail account as less secured account but it's not working.

What I have tried:

i have used below code to send email to the user by my email like abc@gmail.com
MailMessage msg = new MailMessage();
                SmtpClient smtp = new SmtpClient();
                MailAddress from = new MailAddress("abc@gmail.com");
                StringBuilder sb = new StringBuilder();
                msg.IsBodyHtml = true;
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                msg.To.Add(model.Email);
                msg.From = from;
                msg.Subject = "Registration success full on VibExchange ! ";
                msg.Body += " <html>";
                msg.Body += "<body>";
                msg.Body += "<table>";
                msg.Body += "<tr>";
                msg.Body += "<td>Thank you for registering on VibExChange. Your User Name and Password is : </td>";
                msg.Body += "</tr>";
                msg.Body += "<tr>";
                msg.Body += "<td>User Name : </td><td>" + model.UserName + "</td>";
                msg.Body += "</tr>";
                msg.Body += "<tr>";
                msg.Body += "<td>Password : </td><td>" + model.Password + "</td>";
                msg.Body += "</tr>";
                msg.Body += "<tr>";
                msg.Body += "<td>Email Pin : </td><td>" + EmailVerification.ToString() + "</td>";
                msg.Body += "</tr>";
                msg.Body += "<tr>";
                msg.Body += "<td>for Email Verification </td><td><a href='http://www.vibration-service.com/Home/EmailVerification'> Click Here </a></td>";
                msg.Body += "</tr>";
                msg.Body += "<td>for more information </td><td><a href='www.vibration-service.com'> Click Here </a></td>";
                msg.Body += "</tr>";
                msg.Body += "</table>";
                msg.Body += "</body>";
                msg.Body += "</html>";
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl = true;
                smtp.Credentials = new NetworkCredential("abc@gmail.com", "1857");

                smtp.Send(msg);
                msg.Dispose();
Posted
Comments
Richard MacCutchan 4-Oct-20 12:30pm    
Google requires secure authentication for users of its SMTP service.
Member 14743579 4-Oct-20 12:52pm    
any changes required in this code so please tell me or you have other solution for my code or problem then suggest me and how can i give a google secure authentication for users of its smtp service.
Richard MacCutchan 4-Oct-20 12:53pm    
This question has been answered many times - look at the links on the right of this page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900