我想在asp.net中使用PasswordRecovery控件恢复密码,但是当我点击提交按钮。我得到这样的消息:如何配置smtp设置?
错误的命令序列。服务器响应是:此邮件服务器在尝试发送到非本地电子邮件地址时需要进行身份验证。请检查您的邮件客户端设置,或与您的管理员联系,以验证为此服务器 定义了域或地址。 这是我的html代码:
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server"
style="font-family: Tahoma; font-size: small"
onsendingmail="PasswordRecovery1_SendingMail" >
<MailDefinition BodyFileName="../User Pages/RecoveryPass.htm" From="[email protected]"
IsBodyHtml="True" Subject="بازیابی کلمه ی عبور" Priority="High"></MailDefinition>
<UserNameTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:resource, passrecovery %>"
style="font-size: small; font-family: Tahoma"></asp:Label></td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"></asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="PasswordRecovery1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="<%$ Resources:resource, submit %>"
ValidationGroup="PasswordRecovery1" Font-Names="tahoma"
Font-Size="X-Small" Width="80px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</UserNameTemplate>
</asp:PasswordRecovery>
,这是后面的代码:
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
SmtpClient smtp = new SmtpClient();
smtp.Send(e.Message);
}
,这是在web.config中 SMTP设置:
<system.net>
<mailSettings >
<smtp >
<network host="mail.domainname.com" userName="[email protected]" password ="password" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>
这些的arent解决我的问题 –