0
我正在使用ASP.NET成员资格提供程序。我想要设置密码恢复,如here。我正在使用Visual Studio 2012中默认的IIS Express。但它看起来像IIS Express不支持SMTP,因为它的回答为here。IIS Express上的PasswordRecovery
那么我有什么选择去设置密码恢复?
我正在使用ASP.NET成员资格提供程序。我想要设置密码恢复,如here。我正在使用Visual Studio 2012中默认的IIS Express。但它看起来像IIS Express不支持SMTP,因为它的回答为here。IIS Express上的PasswordRecovery
那么我有什么选择去设置密码恢复?
一个解决方案我发现没有安装任何东西,是使用Gmail。因为它在这里讨论了http://forums.asp.net/t/1124257.aspx/1 它迄今为止的工作非常好,用于开发目的。
所以从那个职位。
这是在web配置邮件设置应该是什么样子:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="false" host="smtp.gmail.com" port="587" userName=username" password="xxxxxxxxxxxx" />
</smtp>
</mailSettings>
</system.net>
aspx页面:
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server"
onsendingmail="PasswordRecovery1_SendingMail">
</asp:PasswordRecovery>
后面的代码(C#):
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
MailMessage mm = new MailMessage();
mm.From = e.Message.From;
mm.Subject = e.Message.Subject.ToString();
mm.To.Add(e.Message.To[0]);
mm.Body = e.Message.Body;
SmtpClient smtp = new SmtpClient();
smtp.EnableSsl = true;
smtp.Send(mm);
e.Cancel = true;
}
在我的dev环境我使用http://smtp4dev.codeplex.com/快速,简单,效果很好! – cheesemacfly 2013-04-04 18:01:15
感谢@cheesemacfly的建议。我结束了使用Gmail。工作很好。 – btevfik 2013-04-05 00:00:54