My WinForms app keeps give me an error saying
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.
Here's the source code:
if (signedin)
{
MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress(emailaddressstr);
mail.To.Add(totxt.Text);
mail.Subject = richTextBox2.Text;
mail.Body = emailtext.Text;
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential(emailaddressstr, emailpasswordstr);
smtp.EnableSsl = true;
smtp.Send(mail);
}