('smtp-password', 'password'), # password for SMTP AUTH
('smtp-server', 'smtp.yourisp.net:25'),
('smtp-ssl', str(False)), # Connect to the SMTP server using SSL
+ ('smtp-ssl-protocol', 'SSLv3'), # TLS/SSL version to use on STARTTLS when not using 'smtp-ssl'
# IMAP configuration
('imap-auth', str(False)), # set to True to use IMAP auth.
('imap-username', 'username'), # username for IMAP authentication
import imaplib as _imaplib
import io as _io
import smtplib as _smtplib
+import ssl as _ssl
import subprocess as _subprocess
import sys as _sys
import time as _time
password = config.get(section, 'smtp-password')
try:
if not ssl:
- smtp.starttls()
+ protocol_name = config.get(section, 'smtp-ssl-protocol')
+ protocol = getattr(_ssl, 'PROTOCOL_{}'.format(protocol_name))
+ try:
+ smtp.starttls(context=_ssl.SSLContext(protocol=protocol))
+ except TypeError:
+ # Python 3.2 or earlier
+ smtp.starttls()
smtp.login(username, password)
except KeyboardInterrupt:
raise