Refactoring of mailer