title: how to configure smtp settings?
body: <p>I wanted to recover password using PasswordRecovery control in asp.net .but when I clicked on submit button .I have got this message that :</p>
  
  <p>Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server
  .
  this is my html code:</p>
  
  <pre><code>&lt;asp:PasswordRecovery ID="PasswordRecovery1" runat="server" 
            style="font-family: Tahoma; font-size: small" 
            onsendingmail="PasswordRecovery1_SendingMail" &gt;
            &lt;MailDefinition BodyFileName="../User Pages/RecoveryPass.htm" From="info@shirinfam.com"
              IsBodyHtml="True" Subject="بازیابی کلمه ی عبور" Priority="High"&gt;&lt;/MailDefinition&gt;
          &lt;UserNameTemplate&gt;
              &lt;table cellpadding="1" cellspacing="0" style="border-collapse:collapse;"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;table cellpadding="0"&gt;
                              &lt;tr&gt;
                                  &lt;td align="center" colspan="2"&gt;
                                      &amp;nbsp;&lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td align="center" colspan="2"&gt;
                                      &lt;asp:Label ID="Label1" runat="server" 
                                          Text="&lt;%$ Resources:resource, passrecovery %&gt;" 
                                          style="font-size: small; font-family: Tahoma"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td align="right"&gt;
                                      &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"&gt;&lt;/asp:Label&gt;
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;asp:TextBox ID="UserName" runat="server"&gt;&lt;/asp:TextBox&gt;
                                      &lt;asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                          ControlToValidate="UserName" ErrorMessage="User Name is required." 
                                          ToolTip="User Name is required." ValidationGroup="PasswordRecovery1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td align="center" colspan="2" style="color:Red;"&gt;
                                      &lt;asp:Literal ID="FailureText" runat="server" EnableViewState="False"&gt;&lt;/asp:Literal&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td align="right" colspan="2"&gt;
                                      &lt;asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="&lt;%$ Resources:resource, submit %&gt;" 
                                          ValidationGroup="PasswordRecovery1" Font-Names="tahoma" 
                                          Font-Size="X-Small" Width="80px" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/UserNameTemplate&gt;
  &lt;/asp:PasswordRecovery&gt;
  </code></pre>
  
  <p>and this is the code behind:</p>
  
  <pre><code>protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
      {
          SmtpClient smtp = new SmtpClient();
  
          smtp.Send(e.Message);
      }
  </code></pre>
  
  <p>and this is smtp settings in web.config
  :</p>
  
  <pre><code> &lt;system.net&gt;
      &lt;mailSettings &gt;
        &lt;smtp &gt;
          &lt;network host="mail.domainname.com" userName="info@dominname.com" password ="password" defaultCredentials="false"/&gt;
        &lt;/smtp&gt;
            &lt;/mailSettings&gt;
    &lt;/system.net&gt;
  </code></pre>