improve SMTP SSL support

This commit is contained in:
Davide Alberani 2021-12-25 16:07:30 +01:00
parent 89ed643f6b
commit 1ddfb76c85

View file

@ -309,6 +309,10 @@ def send_email(to, subject='diffido', body='', from_=None):
args[key] = value args[key] = value
try: try:
if use_ssl: if use_ssl:
for key in ('ssl_keyfile', 'ssl_certfile', 'ssl_context'):
if key in args:
args[key.replace('ssl_', '')] = args[key]
del args[key]
logger.debug('STMP SSL connection with args: %s' % repr(args)) logger.debug('STMP SSL connection with args: %s' % repr(args))
with smtplib.SMTP_SSL(**args) as s: with smtplib.SMTP_SSL(**args) as s:
if username: if username: