The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required
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 atI searched around and there are variety of security settings required by G Suite.
- A strong password. I create a new strong password. Confirmed.
- 2-factor auth is off. Confirmed.
- 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:
- SMTP relay service is setup and configured. Here is screenshot of my settings: (as you can see, I have the least secure settings)
Any help anyone?
1 Answer
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.