title: The SMTP server requires a secure connection or the client was not authenticated
body: <p>in my forgot password page user enters email id and clicks on submit button,the submit click event sends a mail on his emailid,,now i m getting an error that smtp server requirs a secure connection or the client was not authenticated,,let me show my code</p>
  
  <pre><code> protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
      {
          if (Page.IsValid)
          {
              PasswordRecovery1.MailDefinition.From = "victorzoya@gmail.com";
  
              e.Message.IsBodyHtml = false;
              e.Message.Subject = "Please read below to reset your password.";
  
              e.Message.Body = e.Message.Body.Replace("&lt;%email%&gt;", PasswordRecovery1.UserName);
  
              SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["DSN"]);
              SqlCommand userid = new SqlCommand("SELECT UserId from aspnet_Users WHERE UserName=@UserName", connection);
              connection.Open();
              userid.Parameters.Add("@UserName", SqlDbType.VarChar, 50);
              userid.Parameters["@UserName"].Value = PasswordRecovery1.UserName;
              SqlDataReader result = userid.ExecuteReader();
              string UserId = "";
              while (result.Read())
              {
                  object obValue = result.GetValue(0);
                  UserId = obValue.ToString();
              }
              connection.Close();
              string link = "http://www.fixpic.com/Passwordreset.aspx?userid=" + UserId;
              e.Message.Body = e.Message.Body.Replace("&lt;%resetlink%&gt;", link);
  
              SmtpClient smtpClient = new SmtpClient();
  
              smtpClient.EnableSsl = true;
              smtpClient.Send(e.Message);
  
              e.Cancel = true;
  
          }
      }
  </code></pre>
  
  <p>in web.config i have defined the mail settings as</p>
  
  <pre><code>&lt;mailSettings&gt;
        &lt;smtp deliveryMethod="Network" from="sumitkumarruhela@gmail.com"&gt;
          &lt;network host="smtp.gmail.com" port="587" defaultCredentials="false" /&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
  </code></pre>