Solution: The server response was: 5.7.0 Must issue a STARTTLS command first. i16sm1806350pag.18 – gsmtp
When sending emails via code using Gmail as mail server, we sometime get this error. This blog post explains the error and the solution to the same.
The error occurs when the code tries to authenticate Gmail server using the given credentials over non-SSL layer and does not encrypt the connection.
To resolve this, you need to set EnableSsl property of your SmtpClient class’s object to true as mentioned below –
SmtpClient client = new SmtpClient("smtp.gmail.com"); client.EnableSsl = true;
Hope you like this. Keep learning and sharing! Cheers!