From fffc9e1a745fb3256022120efcd9754f5649dc84 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 17 Mar 2009 22:56:38 +0000 Subject: [PATCH] bug introduced in the migration to the email package (issue 2550531) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4206 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/cgi/client.py | 16 ++++++++-------- roundup/mailer.py | 6 ++++-- roundup/roundupdb.py | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0072ce3..fef50e9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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) diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 354be09..6b74e4b 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -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: diff --git a/roundup/mailer.py b/roundup/mailer.py index 9c70852..f52e20c 100644 --- a/roundup/mailer.py +++ b/roundup/mailer.py @@ -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, diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 7c3106c..fe9c8e3 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -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): -- 2.30.2