Separated mailer from the entry point of the program. Added logging capabilities.