Modularize the mailer.
Fix bug in previous commit.