Pregunta

I am using the ASP.NET membership provider. And I want to set up Password Recovery as in here. I am using the IIS Express that is default in Visual Studio 2012. But it looks like IIS Express does not support SMTP as it was answered here.

So what are my options to go about setting up a password recovery?

¿Fue útil?

Solución

one solution I found without installing anything, was to use gmail. as it is discussed over here http://forums.asp.net/t/1124257.aspx/1 it works pretty well so far for development purposes.

so from that post.

This is what the mail setting in the web config should look like :

<system.net>
     <mailSettings>
       <smtp deliveryMethod="Network" from="username@gmail.com">
         <network defaultCredentials="false" host="smtp.gmail.com" port="587" userName=username" password="xxxxxxxxxxxx" />
       </smtp>
     </mailSettings>
   </system.net> 

aspx page :

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" 
        onsendingmail="PasswordRecovery1_SendingMail">
     </asp:PasswordRecovery>

code behind (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; 
    } 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top