diff options
author | Mark Sapiro <mark@msapiro.net> | 2016-05-06 14:44:28 -0700 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2016-05-06 14:44:28 -0700 |
commit | d2145608089777cd27175763cf9f71ca2a3159f5 (patch) | |
tree | 2a785262135176b828953b0c85dd6196a6a73bf9 /Mailman/Handlers | |
parent | 6a615a1e6c6b3b03c3d8e334e6b097f29c9c975a (diff) | |
download | mailman2-d2145608089777cd27175763cf9f71ca2a3159f5.tar.gz mailman2-d2145608089777cd27175763cf9f71ca2a3159f5.tar.xz mailman2-d2145608089777cd27175763cf9f71ca2a3159f5.zip |
Implement SASL and STARTTLS in SMTPDirect.py.
Diffstat (limited to 'Mailman/Handlers')
-rw-r--r-- | Mailman/Handlers/SMTPDirect.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py index 32b03423..3b489c2f 100644 --- a/Mailman/Handlers/SMTPDirect.py +++ b/Mailman/Handlers/SMTPDirect.py @@ -63,6 +63,36 @@ class Connection: self.__conn = smtplib.SMTP() self.__conn.set_debuglevel(mm_cfg.SMTPLIB_DEBUG_LEVEL) self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT) + if mm_cfg.SMTP_AUTH: + if mm_cfg.SMTP_USE_TLS: + try: + self.__conn.starttls() + except SMTPException, e: + syslog('smtp-failure', 'SMTP TLS error: %s', e) + self.quit() + raise + try: + self.__conn.ehlo(mm_cfg.SMTP_HELO_HOST) + except SMTPException, e: + syslog('smtp-failure', 'SMTP EHLO error: %s', e) + self.quit() + raise + try: + self.__conn.login(mm_cfg.SMTP_USER, mm_cfg.SMTP_PASSWD) + except smtplib.SMTPHeloError, e: + syslog('smtp-failure', 'SMTP HELO error: %s', e) + self.quit() + raise + except smtplib.SMTPAuthenticationError, e: + syslog('smtp-failure', 'SMTP AUTH error: %s', e) + self.quit() + raise + except smtplib.SMTPException, e: + syslog('smtp-failure', + 'SMTP - no suitable authentication method found: %s', e) + self.quit() + raise + self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION def sendmail(self, envsender, recips, msgtext): |