mailer refactor