问题
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