changeset 1581:67377fd685be beta

applied smth_auth options update patch
author Les Peabody <lpeabody@ccom.unh.edu>
date Thu, 20 Oct 2011 11:58:11 -0400
parents f0437ae274df
children e060b2be1ea5
files rhodecode/config/deployment.ini_tmpl rhodecode/lib/celerylib/tasks.py rhodecode/lib/smtp_mailer.py
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/deployment.ini_tmpl	Thu Oct 20 00:36:11 2011 +0200
+++ b/rhodecode/config/deployment.ini_tmpl	Thu Oct 20 11:58:11 2011 -0400
@@ -24,6 +24,8 @@
 #smtp_port = 
 #smtp_use_tls = false
 #smtp_use_ssl = true
+# Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.)
+#smtp_auth = 
 
 [server:main]
 ##nr of threads to spawn
--- a/rhodecode/lib/celerylib/tasks.py	Thu Oct 20 00:36:11 2011 +0200
+++ b/rhodecode/lib/celerylib/tasks.py	Thu Oct 20 11:58:11 2011 -0400
@@ -356,9 +356,10 @@
     tls = str2bool(email_config.get('smtp_use_tls'))
     ssl = str2bool(email_config.get('smtp_use_ssl'))
     debug = str2bool(config.get('debug'))
+    smtp_auth = email_config.get('smtp_auth')
 
     try:
-        m = SmtpMailer(mail_from, user, passwd, mail_server,
+        m = SmtpMailer(mail_from, user, passwd, mail_server,smtp_auth,
                        mail_port, ssl, tls, debug=debug)
         m.send(recipients, subject, body)
     except:
--- a/rhodecode/lib/smtp_mailer.py	Thu Oct 20 00:36:11 2011 +0200
+++ b/rhodecode/lib/smtp_mailer.py	Thu Oct 20 11:58:11 2011 -0400
@@ -36,6 +36,7 @@
 from email import encoders
 
 
+
 class SmtpMailer(object):
     """SMTP mailer class
 
@@ -49,7 +50,7 @@
 
     """
 
-    def __init__(self, mail_from, user, passwd, mail_server,
+    def __init__(self, mail_from, user, passwd, mail_server,smtp_auth,
                     mail_port=None, ssl=False, tls=False, debug=False):
 
         self.mail_from = mail_from
@@ -60,6 +61,7 @@
         self.ssl = ssl
         self.tls = tls
         self.debug = debug
+        self.auth = smtp_auth
 
     def send(self, recipients=[], subject='', body='', attachment_files=None):
 
@@ -78,6 +80,8 @@
             smtp_serv.set_debuglevel(1)
 
         smtp_serv.ehlo()
+        if self.auth:
+            smtp_serv.esmtp_features["auth"] = self.auth
 
         #if server requires authorization you must provide login and password
         #but only if we have them