The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required

1

I'm attempting to send email using G Suite's SMTP relay service. Using C#, my code snippet looks like this:

string message = "<em>It's great to use HTML in mail!!</em>"
var client = new SmtpClient("smtp.gmail.com", 587);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(_senderEmailAddress, _senderPassword);
client.EnableSsl = true;
client.Send(message);

However, this results in the following exception:

System.Net.Mail.SmtpException
  HResult=0x80131500
  Message=The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at

I searched around and there are variety of security settings required by G Suite.

  1. A strong password. I create a new strong password. Confirmed.
  2. 2-factor auth is off. Confirmed.
  3. Access to less secure apps is enabled. Here is screenshot of my settings, the first is the admin console enabling it for users, the second is the user enabling it:

enter image description here

enter image description here

  1. SMTP relay service is setup and configured. Here is screenshot of my settings: (as you can see, I have the least secure settings)

enter image description here

Any help anyone?

smtp
c#
google-workspace
asked on Super User Sep 3, 2020 by sapbucket • edited Sep 3, 2020 by sapbucket

1 Answer

1

The above code and settings are CORRECT. The issue was that my password was not strong. I had been using a password tool to generate a password, which it declared as STRONG. However, G Suite did not. And shame on G Suite: it does not let you know.

answered on Super User Sep 3, 2020 by sapbucket

User contributions licensed under CC BY-SA 3.0