public ActionResult ForgotPassword(ForgotPasswordViewModel forgot) { if (ModelState.IsValid && forgot.validate(ModelState)) { photogEntities db = new photogEntities(); var users = db.Users.FirstOrDefault(x => x.email.ToLower() == forgot.Email.ToLower()); if (users != null) { users.isForgotPassword = true; users.verifiedKey = (new Backbone()).Random(8); db.SaveChanges(); string url = string.Format("https://{0}/Account/Validate?key={1}", Request.Url.Authority, users.verifiedKey); string emailContent = String.Format("Click Here to reset your password : {0}", url); var client = new SmtpClient("smtp.titan.email", 587) { Credentials = new NetworkCredential("*****@*****.**", "RareMaHZUU") }; client.Send("*****@*****.**", forgot.Email, "Verify your Account", emailContent); } ViewBag.Email = forgot.Email.ToLower(); return(View("ValidateEmail")); } return(View("ForgotPasswordMain")); }