mailer refactoring