Fix exceptions when using the email mailer on Python 3.