Changes related to PEP coding style and add exception handling for sending mail.