title: the SMTP server requires a secure connection or the client was not authenticated. The server response was 5.5.1, Authentication required
body: <p>I have been trying to get my application to send an email for over an hour now, and i've tried everything i've found online but i still get the exception mentioned in the title of my question.</p>
  
  <p>Here is the code i used:</p>
  
  <pre><code>        SmtpClient client = new SmtpClient();
          client.Host = "smtp.gmail.com";
          client.Port = 587;
          client.Credentials = new NetworkCredential("Sender email", "Sender email password");
          client.EnableSsl = true;
          client.UseDefaultCredentials = false;
          client.DeliveryMethod = SmtpDeliveryMethod.Network;
  
          MailMessage mail = new MailMessage();
          mail.From = new MailAddress("Sender email", "Sender");
          mail.To.Add(new MailAddress("My email"));
          mail.Subject = "TEST";
          mail.IsBodyHtml = true;
          mail.Body = sb.ToString();
  
          client.Send(mail);
  </code></pre>
  
  <p>I have allowed access to less secure apps on my account.
  I have also tried enabling 2FA and then generating an application specific password, but the exception stays.</p>