Adds STARTTLS support to SMTP notifications
This commit is contained in:
parent
85e637d017
commit
658e065f23
@ -117,7 +117,7 @@ class Config:
|
||||
"reload = off", "profile = off",
|
||||
"[smtp]",
|
||||
"username = ", "password = ",
|
||||
"host = localhost", "port = 465", "ssl = on",
|
||||
"host = localhost", "port = 465", "security = ssl",
|
||||
"to = ", "from = ",
|
||||
"[guard]",
|
||||
"enabled = true",
|
||||
|
@ -57,9 +57,12 @@ class SMTP(object):
|
||||
uwsgi.spooler = spooler
|
||||
|
||||
def __enter__(self):
|
||||
klass = (smtplib.SMTP_SSL if self.conf.getboolean('ssl') else smtplib.SMTP)
|
||||
klass = (smtplib.SMTP_SSL if self.conf.get('security') == 'ssl' else smtplib.SMTP)
|
||||
self.client = klass(host=self.conf.get('host'), port=self.conf.getint('port'))
|
||||
|
||||
if self.conf.get('security') == 'starttls':
|
||||
self.client.starttls();
|
||||
|
||||
if self.conf.get('username') and self.conf.get('password'):
|
||||
self.client.login(self.conf.get('username'),
|
||||
self.conf.get('password'))
|
||||
|
Loading…
Reference in New Issue
Block a user