Skip to content

Commit

Permalink
Start TLS before login on SMTP server
Browse files Browse the repository at this point in the history
And do not send not encrypted credentials over network
  • Loading branch information
arnaud-morvan committed Nov 21, 2019
1 parent 8dbe9ab commit f41241a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions commons/c2cgeoportal_commons/lib/email_.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def send_email(
smtp = smtplib.SMTP_SSL(smtp_config['host']) # type: smtplib.SMTP
else:
smtp = smtplib.SMTP(smtp_config['host'])
if smtp_config.get('user', False):
smtp.login(smtp_config['user'], smtp_config['password'])
if smtp_config.get('starttls', False):
smtp.starttls()
if smtp_config.get('user', False):
smtp.login(smtp_config['user'], smtp_config['password'])

smtp.sendmail(from_addr, to_addrs, msg.as_string())
smtp.close()

0 comments on commit f41241a

Please sign in to comment.