Getting error:
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
The code I used is given below:
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(email);
mail.To.Add(email);
mail.Subject = "Test";
mail.Body = html;
mail.IsBodyHtml = true;
using (SmtpClient smtp = new SmtpClient(host, int.Parse(port)))
{
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(email, password);
smtp.EnableSsl = true;
smtp.Send(mail);
}
}