Code

bug introduced in the migration to the email package (issue 2550531)
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 17 Mar 2009 22:56:38 +0000 (22:56 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 17 Mar 2009 22:56:38 +0000 (22:56 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4206 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
roundup/cgi/client.py
roundup/mailer.py
roundup/roundupdb.py

index 0072ce3e7bd379f8ff18b6c678398377f71682bd..fef50e946c6aeadebcab5e651198e949f25ab043 100644 (file)
@@ -5,6 +5,7 @@ are given with the most recent entry first.
 
 Fixes:
 - bug introduced into CVS export and view
+- bugs introduced in the migration to the email package (issue 2550531)
 
 
 2009-03-13 1.4.7 (r4202)
index 354be09ad2cc0ddcd3e21f6e7da1f42d203fa880..6b74e4be62f4a870891df681e8c93eeb7b4daebd 100644 (file)
@@ -14,7 +14,7 @@ from roundup.cgi.actions import *
 from roundup.exceptions import *
 from roundup.cgi.exceptions import *
 from roundup.cgi.form_parser import FormParser
-from roundup.mailer import Mailer, MessageSendError
+from roundup.mailer import Mailer, MessageSendError, encode_quopri
 from roundup.cgi import accept_language
 from roundup import xmlrpc
 
@@ -991,13 +991,13 @@ class Client:
                 to = [self.mailer.config.ADMIN_EMAIL]
                 subject = "Templating Error: %s" % exc_info[1]
                 content = cgitb.pt_html()
-                message, writer = self.mailer.get_standard_message(
-                    to, subject)
-                writer.addheader('Content-Transfer-Encoding', 'quoted-printable')
-                body = writer.startbody('text/html; charset=utf-8')
-                content = StringIO(content)
-                quopri.encode(content, body, 0)
-                self.mailer.smtp_send(to, message)
+                message = self.mailer.get_standard_message(to, subject)
+                # delete existing content-type headers
+                del message['Content-type']
+                message['Content-type'] = 'text/html; charset=utf-8'
+                message.set_payload(content)
+                encode_quopri(message)
+                self.mailer.smtp_send(to, str(message))
                 # Now report the error to the user.
                 return self._(error_message)
             except:
index 9c70852317f36fd6a35f087d65d8d11c482f7b95..f52e20c4078911a5fe7c4953708d307f1e64f74b 100644 (file)
@@ -23,6 +23,7 @@ def encode_quopri(msg):
     orig = msg.get_payload()
     encdata = quopri.encodestring(orig)
     msg.set_payload(encdata)
+    del msg['Content-Transfer-Encoding']
     msg['Content-Transfer-Encoding'] = 'quoted-printable'
 
 class Mailer:
@@ -55,7 +56,7 @@ class Mailer:
         Subject and author are encoded using the EMAIL_CHARSET from the
         config (default UTF-8).
 
-        Returns a Message object and body part writer.
+        Returns a Message object.
         '''
         # encode header values if they need to be
         charset = getattr(self.config, 'EMAIL_CHARSET', 'utf-8')
@@ -70,8 +71,8 @@ class Mailer:
             message = MIMEMultipart()
         else:
             message = Message()
+            message.set_type('text/plain')
             message.set_charset(charset)
-            message['Content-Type'] = 'text/plain; charset="%s"'%charset
 
         try:
             message['Subject'] = subject.encode('ascii')
@@ -115,6 +116,7 @@ class Mailer:
         """
         message = self.get_standard_message(to, subject, author)
         message.set_payload(content)
+        encode_quopri(message)
         self.smtp_send(to, str(message))
 
     def bounce_message(self, bounced_message, to, error,
index 7c3106c5889dbbf477e2f38a0be529e2a4f51ff3..fe9c8e315b947cd9b0ce4f8b2090560f1dcc4d47 100644 (file)
@@ -499,9 +499,9 @@ class IssueClass:
                 encode_quopri(message)
 
             if first:
-                mailer.smtp_send(sendto + bcc_sendto, message)
+                mailer.smtp_send(sendto + bcc_sendto, str(message))
             else:
-                mailer.smtp_send(sendto, message)
+                mailer.smtp_send(sendto, str(message))
             first = False
 
     def email_signature(self, nodeid, msgid):