please help me to solve
error->Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
my code is like below
- [HttpPost]
- public ViewResult Index(mail_sending.Models.MailModel _objModelMail)
- {
- if (ModelState.IsValid)
- {
- MailMessage mail = new MailMessage();
- mail.To.Add(_objModelMail.To);
- mail.From = new MailAddress(_objModelMail.From);
- mail.Subject = _objModelMail.Subject;
- string Body = _objModelMail.Body;
- mail.Body = Body;
- mail.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Port = 587;
- smtp.UseDefaultCredentials = false;
- smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "shushiladevi");
- smtp.EnableSsl = true;
- smtp.Send(mail);
- return View("Index", _objModelMail);
- }
- else
- {
- return View();
- }
- }