I'm trying to use logging
's SMTPHandler
. From Python 3.3 on, you can specify a timeout
keyword argument. If you add that argument in older versions, it fails. To get around this, I used the following:
import sys
if sys.version_info >= (3, 3):
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT, timeout=20.0)
else:
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT)
Is there a better way of doing this?