The SMTP server requires a secure connection or the client was not authenticated
Solution 1
Gmail requires you to use a secure connection. This can be set in your web.config like this:
<network host="smtp.gmail.com" enableSsl="true" ... />
Solution 2
Gmail is blocking your SQL Server instance from sending emails through it. Once you encounter your error, if you login to gmail and try to compose a message, it'll notify you of an access that it blocked. You just need to tell Gmail that this was ligitimate and to allow future logins from sqlserver.
This should do the trick!
Dmitry Makovetskiyd
Updated on July 09, 2022Comments
-
Dmitry Makovetskiyd almost 2 years
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. k12sm3795394wby.16
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. k12sm3795394wby.16
Source Error:
I am using createUserWizard.. it has a mailing option in its properties that i set using the designer (VS2010). When I used code it worked!, but with that control it doesnt. I wonder why!!
Here is my web.config file:
<system.net> <mailSettings> <smtp from="[email protected]"> <network host="smtp.gmail.com" defaultCredentials="false" port="587" userName="**********" password="*****"/> </smtp> </mailSettings> </system.net>
But I doubt the control uses that setting.
-
Dennis Traub over 12 years@DmitryMakovetskiyd please accept the answer if it was helpful. Thanks.
-
Ivan Jovović about 9 yearsThe page for mentioned settings is here: google.com/settings/security/lesssecureapps
-
Augusto Barreto over 8 years@IvanJovovic Indeed, enabling access to less secure apps solved the issue. I forgot about that. Thanks!