Merge pull request #48 from chimo/starttls

Adds STARTTLS support to SMTP notifications
This commit is contained in:
Martin Zimmermann 2013-12-23 04:43:49 -08:00
commit ab27ce5450
2 changed files with 5 additions and 2 deletions

View File

@ -117,7 +117,7 @@ class Config:
"reload = off", "profile = off", "reload = off", "profile = off",
"[smtp]", "[smtp]",
"username = ", "password = ", "username = ", "password = ",
"host = localhost", "port = 465", "ssl = on", "host = localhost", "port = 465", "security = ssl",
"to = ", "from = ", "to = ", "from = ",
"[guard]", "[guard]",
"enabled = true", "enabled = true",

View File

@ -57,9 +57,12 @@ class SMTP(object):
uwsgi.spooler = spooler uwsgi.spooler = spooler
def __enter__(self): 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')) 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'): if self.conf.get('username') and self.conf.get('password'):
self.client.login(self.conf.get('username'), self.client.login(self.conf.get('username'),
self.conf.get('password')) self.conf.get('password'))