diff roundup/mailer.py @ 2626:e49e6c7b14fb

fix incompatibilities with new configuration; added MAIL_DEBUG config option; added vim modeline
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Sun, 25 Jul 2004 15:25:44 +0000
parents 6deda7ff3b2a
children 75b4c2c32cf3 8fcee705ebdb
line wrap: on
line diff
--- a/roundup/mailer.py	Sun Jul 25 15:22:54 2004 +0000
+++ b/roundup/mailer.py	Sun Jul 25 15:25:44 2004 +0000
@@ -1,7 +1,7 @@
 """Sending Roundup-specific mail over SMTP.
 """
 __docformat__ = 'restructuredtext'
-# $Id: mailer.py,v 1.9 2004-03-25 22:53:26 richard Exp $
+# $Id: mailer.py,v 1.10 2004-07-25 15:25:44 a1s Exp $
 
 import time, quopri, os, socket, smtplib, re
 
@@ -21,7 +21,8 @@
 
         # set to indicate to roundup not to actually _send_ email
         # this var must contain a file to write the mail to
-        self.debug = os.environ.get('SENDMAILDEBUG', '')
+        self.debug = os.environ.get('SENDMAILDEBUG', '') \
+            or config["MAIL_DEBUG"]
 
     def get_standard_message(self, to, subject, author=None):
         '''Form a standard email message from Roundup.
@@ -64,8 +65,8 @@
         # finally, an aid to debugging problems
         writer.addheader('X-Roundup-Version', __version__)
 
-        writer.addheader('MIME-Version', '1.0')       
-        
+        writer.addheader('MIME-Version', '1.0')
+
         return message, writer
 
     def standard_message(self, to, subject, content, author=None):
@@ -136,7 +137,7 @@
         writer.lastpart()
 
         self.smtp_send(to, message)
-        
+
     def smtp_send(self, to, message):
         """Send a message over SMTP, using roundup's config.
 
@@ -168,29 +169,18 @@
     ''' Open an SMTP connection to the mailhost specified in the config
     '''
     def __init__(self, config):
-        
+
         smtplib.SMTP.__init__(self, config.MAILHOST)
 
-        # use TLS?
-        use_tls = getattr(config, 'MAILHOST_TLS', 'no')
-        if use_tls == 'yes':
-            # do we have key files too?
-            keyfile = getattr(config, 'MAILHOST_TLS_KEYFILE', '')
-            if keyfile:
-                certfile = getattr(config, 'MAILHOST_TLS_CERTFILE', '')
-                if certfile:
-                    args = (keyfile, certfile)
-                else:
-                    args = (keyfile, )
-            else:
-                args = ()
-            # start the TLS
-            self.starttls(*args)
+        # start the TLS if requested
+        if config["MAIL_TLS"]:
+            self.starttls(config["MAIL_TLS_KEYFILE"],
+                config["MAIL_TLS_CERFILE"])
 
         # ok, now do we also need to log in?
-        mailuser = getattr(config, 'MAILUSER', None)
+        mailuser = config["MAIL_USERNAME"]
         if mailuser:
-            self.login(*config.MAILUSER)
+            self.login(mailuser, config["MAIL_PASSWORD"])
 
 # use the 'email' module, either imported, or our copied version
 try :
@@ -207,3 +197,5 @@
             name = escapesre.sub(r'\\\g<0>', name)
             return '%s%s%s <%s>' % (quotes, name, quotes, address)
         return address
+
+# vim: set et sts=4 sw=4 :

Roundup Issue Tracker: http://roundup-tracker.org/