title: ASP.Net 3.5 password recovery SMTP settings
body: <p>Within ASP.Net - I'm using the built in password recovery wizard.</p>
  
  <p>Is there any way of adding SMTP authentication to the Mail Authentication wizard - without having to add it to the web.config?  Or can it be injected somewhere in the code-behind?</p>
  
  <p>My aspx code is below - there is currently no code-behind:</p>
  
  <pre><code>       &lt;asp:PasswordRecovery ID="PasswordRecovery1" runat="server" borderStyle="None" 
          borderWidth="1px"  Font-Size="10pt" Font-Names="Verdana" onsendingmail="PasswordRecovery1_SendingMail"&gt;
      &lt;TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" /&gt;
      &lt;MailDefinition From="info@mydomain.co.uk" Priority="High" 
          Subject="My Domain - new, temporary password" BodyFileName="forgotpassword.txt"&gt;
      &lt;/MailDefinition&gt;
      &lt;UserNameTemplate&gt;
          &lt;table border="0" cellpadding="1" cellspacing="0" 
              style="border-collapse:collapse;"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;table border="0" cellpadding="0"&gt;
  
                          &lt;tr&gt;
                              &lt;td align="center" colspan="2" style="font-family:Arial;font-size:Small;"&gt;
                                  Enter your User Name to receive your password.&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td align="right" style="font-family:Arial;font-size:Small;"&gt;
                                  &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"&gt;User Name:&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="Submit" 
                                      ValidationGroup="PasswordRecovery1" /&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>Currently I just get the message:</p>
  
  <blockquote>
    <p>System.Net.Mail.SmtpFailedRecipientException
    Mailbox unavailable. 
    The server response was: must be authenticated</p>
  </blockquote>