Refactor mail to be more configurable