diff rhodecode/lib/smtp_mailer.py @ 1639:95c3e33ef32e

merged upto rev 019026a8cf67
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 02 Nov 2011 22:19:47 +0200
parents 752b0a7b7679 8e77c75bd65a
children
line wrap: on
line diff
--- a/rhodecode/lib/smtp_mailer.py	Wed Nov 02 20:33:02 2011 +0200
+++ b/rhodecode/lib/smtp_mailer.py	Wed Nov 02 22:19:47 2011 +0200
@@ -39,7 +39,7 @@
 class SmtpMailer(object):
     """SMTP mailer class
 
-    mailer = SmtpMailer(mail_from, user, passwd, mail_server,
+    mailer = SmtpMailer(mail_from, user, passwd, mail_server, smtp_auth
                         mail_port, ssl, tls)
     mailer.send(recipients, subject, body, attachment_files)
 
@@ -49,8 +49,8 @@
 
     """
 
-    def __init__(self, mail_from, user, passwd, mail_server,
-                    mail_port=None, ssl=False, tls=False, debug=False):
+    def __init__(self, mail_from, user, passwd, mail_server, smtp_auth=None,
+                 mail_port=None, ssl=False, tls=False, debug=False):
 
         self.mail_from = mail_from
         self.mail_server = mail_server
@@ -60,6 +60,7 @@
         self.ssl = ssl
         self.tls = tls
         self.debug = debug
+        self.auth = smtp_auth
 
     def send(self, recipients=[], subject='', body='', attachment_files=None):
 
@@ -78,9 +79,11 @@
             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
+        # if server requires authorization you must provide login and password
+        # but only if we have them
         if self.user and self.passwd:
             smtp_serv.login(self.user, self.passwd)
 
@@ -156,6 +159,7 @@
         if isinstance(msg_file, str):
             return open(msg_file, "rb").read()
         else:
-            #just for safe seek to 0
+            # just for safe seek to 0
             msg_file.seek(0)
             return msg_file.read()
+