0

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);
        }
Ken White
  • 120,522
  • 13
  • 212
  • 426
  • https://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not – dr.null Jan 02 '22 at 04:40

0 Answers0