Why am I not getting a password reset email?

大憨熊 提交于 2019-12-13 08:08:12

问题


In the first 8 minutes of this tutorial, the developer tells you to uncomment the code in the forgotpassword() in the account controller, the email confirmation in the if, and finally the link to get the forgot password page on the login screen. He then tells you to write in the following code in your Identity config.

using System.Net.Mail;    
public Task SendAsync(IdentityMessage message)
{
    //Emails will be sent from this address
    var from = "someusername@gmail.com";
    var pass = "somepassword";

    //setting up SMTP client
    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential(from, pass);
    client.EnableSsl = false;

    //Create Email
    var mail = new MailMessage(from, message.Destination);
    mail.Subject = message.Subject;
    mail.Body = message.Body;
    mail.IsBodyHtml = true;

    //Send email
    return client.SendMailAsync(mail);
    // Plug in your email service here to send an email.
    return Task.FromResult(0);
} 

My project builds as it does in the tutorial however, he is able to receive an email in the tutorial but I do not. I double and triple checked my username and password. What did I miss?

来源:https://stackoverflow.com/questions/42447134/why-am-i-not-getting-a-password-reset-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!