starting on line 97:
# send the mail
if not use_ssl:
smtp = smtplib.SMTP(server)
else:
smtp = smtplib.SMTP_SSL(server)
if use_tls:
smtp.starttls()
should be:
# send the mail
if not use_ssl and not use_tls:
smtp = smtplib.SMTP(server)
else:
smtp = smtplib.SMTP_SSL(server)
if use_tls:
smtp.starttls()