Are you getting following script error while using GMAIL as SMTP Server?
system.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.
Solution
Visit https://myaccount.google.com/security and Scroll to find Less Secure App Access or directly visit https://myaccount.google.com/lesssecureapps
Switch on Allow Less Secure Apps
You need to keep this ON till you want your script to use your account’s SMTP. Also you will get a security email alert on your Gmail account and might continue to get whenever it is accessed. In that case check the IP and if it is your server IP you should not be worried much.
Check if the you used correct login credential
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" password="Password" userName="username" port="587" />
</smtp>
</mailSettings>
</system.net>
Set the following in code to false
client.UseDefaultCredentials = true;