在this tutorial的前8分钟,开发人员会告诉您取消注释帐户控制器中forgotpassword()
中的代码,if中的电子邮件确认,最后是取消忘记的链接登录屏幕上的密码页面。然后他告诉您在Identity配置中写下以下代码。
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);
}
我的项目按照教程中的方式构建,但是他能够在教程中收到一封电子邮件,但我没有。我加倍检查我的用户名和密码。我错过了什么?