I am trying to send an email to someone when they forget their password to their account but every time I try it says "The SMTP server requires a secure connection or the client was not authenticated. How do I fix this?
mailLogin = new NetworkCredential(Email, Password);
client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = mailLogin;
client.EnableSsl = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
msg = new MailMessage { From = new MailAddress(Email, Name, Encoding.UTF8) };
msg.To.Add(new MailAddress(Email));
msg.Subject = "Subject";
msg.Body = "Message";
msg.BodyEncoding = Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.Normal;
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userstate = "Sending...";
client.SendAsync(msg, userstate);