diff roundup/mailer.py @ 4215:57dfcc824acc

fix problem with bounce-message if incoming mail has insufficient privilege... ...e.g., user not existing (issue 2550534) Added a regression test for this issue that reproduces the traceback reported in issue 2550534 I'm using a slightly modified variant of the original patch that avoids repeated string-concatenation (which could degenerate to quadratic runtime behaviour for large number of email headers).
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 15 Jul 2009 12:22:35 +0000
parents d5cd6f440396
children 2f4cee0e31e2
line wrap: on
line diff
--- a/roundup/mailer.py	Tue Jul 14 18:21:06 2009 +0000
+++ b/roundup/mailer.py	Wed Jul 15 12:22:35 2009 +0000
@@ -140,24 +140,25 @@
         elif error_messages_to == "both":
             to.append(dispatcher_email)
 
-        message = self.get_standard_message(to, subject)
+        message = self.get_standard_message(to, subject, multipart=True)
 
         # add the error text
-        part = MIMEText(error)
+        part = MIMEText('\n'.join(error))
         message.attach(part)
 
         # attach the original message to the returned message
+        body = []
+        for header in bounced_message.headers:
+            body.append(header)
         try:
             bounced_message.rewindbody()
-        except IOError, message:
-            body.write("*** couldn't include message body: %s ***"
-                       % bounced_message)
+        except IOError, errmessage:
+            body.append("*** couldn't include message body: %s ***" %
+                errmessage)
         else:
-            body.write(bounced_message.fp.read())
-        part = MIMEText(bounced_message.fp.read())
-        part['Content-Disposition'] = 'attachment'
-        for header in bounced_message.headers:
-            part.write(header)
+            body.append('\n')
+            body.append(bounced_message.fp.read())
+        part = MIMEText(''.join(body))
         message.attach(part)
 
         # send

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