Our site needs to send emails to its users, for example when the user forgets the password. To do this comes to the rescue System.Net.Mail.SmtpClient class.
This class automatically uses the SMTP server settings stored in the Web.config file. You just have to add to that file the following tags inside the configuration tag:
<system.net> <mailSettings> <smtp deliveryMethod="Network" from="mail_from"> <network host="my_smtp_server" port="my_smtp_server_port" userName="user_name_smtp" password="password" clientDomain="my_domain" /> </smtp> </mailSettings> </system.net>
In the view Account/Login , you can see, bottom, on the left, the link to Account/ForgotPassword that is the page where the user can reset his password.
In the controller Account, in the action post “ForgotPassword” you make operational, removing them as a comment, the lines of code dedicated to password recovery.
In the file IdentityConfig.cs, in the function
public Task SendAsync(IdentityMessage message)
and replaced to the line
with the following lines of code
var sentFrom = "email@example.com" // System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); // client.EnableSsl = false; // Create the message: var mail = new System.Net.Mail.MailMessage(sentFrom, message.Destination); mail.Subject = message.Subject; mail.Body = message.Body; mail.IsBodyHtml = true; // Send: return client.SendMailAsync(mail);
You have activated the password recovery