The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
try
{
MailMessage mail = new MailMessage();
string to = "[email protected]";
mail.To.Add(to);
mail.From = new MailAddress("[email protected]");
mail.Subject = "Mail";
mail.Body = " HI";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message); Console.ReadLine();
}