I have this error when I try to send an email from c#
MailMessage mail = new MailMessage("from@gmail.com", "to@hotmail.com");
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("from@gmail.com", "pwd");
client.UseDefaultCredentials = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.