public void Send(string resetUrl, PasswordResetRequest request) { ParamIs.NotNull(() => request); MailAddress to; try { to = new MailAddress(request.User.Email); } catch (FormatException x) { log.WarnException("Unable to validate receiver email", x); return; } var mailMessage = new MailMessage(); mailMessage.To.Add(to); mailMessage.Subject = "Password reset requested."; mailMessage.Body = "Hi " + request.User.Name + ",\n\n" + "You (or someone who knows your email address) has requested to reset your password on VocaDB.\n" + "You can perform this action at " + resetUrl + "/" + request.Id + ". If you did not request this action, you can ignore this message.\n\n" + "- VocaDB mailer"; var client = new SmtpClient(); try { client.Send(mailMessage); } catch (SmtpException x) { log.ErrorException("Unable to send mail", x); } }
public void SetUp() { var hashedPass = LoginManager.GetHashedPass("already_exists", "123", 0); userWithEmail = new User("already_exists", hashedPass, "*****@*****.**", 0) { Id = 123 }; userWithoutEmail = new User("no_email", "222", string.Empty, 321) { Id = 321 }; repository = new FakeUserRepository(userWithEmail, userWithoutEmail); repository.Add(userWithEmail.Options); permissionContext = new FakePermissionContext(new UserWithPermissionsContract(userWithEmail, ContentLanguagePreference.Default)); stopForumSpamClient = new FakeStopForumSpamClient(); mailer = new FakeUserMessageMailer(); data = new UserQueries(repository, permissionContext, new FakeEntryLinkFactory(), stopForumSpamClient, mailer, new FakeUserIconFactory(), new FakeObjectCache()); softBannedIPs = new HostCollection(); request = new PasswordResetRequest(userWithEmail) { Id = Guid.NewGuid() }; repository.Add(request); }