Tuesday 31 December 2013

The SMTP(GMAIL) server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first.

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" ... />
and Programmatically
            SmtpClient client = new SmtpClient(server, port);
            client.EnableSsl = true;
            client.UseDefaultCredentials = false;
            // Add credentials if the SMTP server requires them.
            client.Credentials = new NetworkCredential(username, password);