public bool EmailForResetPassword(string email)
        {
            List <User> master = _repo.GetAllDetails();

            foreach (User mast in master)
            {
                if (mast.Email == email)
                {
                    var message = new MimeMessage();
                    message.From.Add(new MailboxAddress(_config["EmailConfig:Title"], _config["EmailConfig:FromEmail"])); //mail title and mail from(Email)
                    message.To.Add(new MailboxAddress(email));                                                            // Mail to(Email)
                    message.Subject = _config["EmailConfig:SubjectForEmailReset"];                                        //mail subject
                    var bodyBuilder = new BodyBuilder();
                    //body of the mail
                    bodyBuilder.HtmlBody = "Click here to reset your password-  http://localhost:4200/app-register-user-with-new-password/" + 1;
                    message.Body         = bodyBuilder.ToMessageBody();

                    using (var client = new SmtpClient())
                    {
                        //required field for email
                        client.Connect(_config["EmailConfig:Domain"], 587, false);
                        client.Authenticate(_config["EmailConfig:FromEmail"], _config["EmailConfig:Password"]);
                        client.Send(message);
                        client.Disconnect(true);
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
 //this method shows the list of all registered users
 public List <User> GetAllDetails()
 {
     return(_context.GetAllDetails());
 }