1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: roundupdb.py,v 1.98 2004-02-23 05:29:05 richard Exp $
18+ # $Id: roundupdb.py,v 1.99 2004-02-29 00:35:55 richard Exp $
1919
2020"""Extending hyperdb with types specific to issue-tracking.
2121"""
@@ -207,10 +207,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
207207 self .db .config .MAIL_DOMAIN )
208208 messages .set (msgid , messageid = messageid )
209209
210- # send an email to the people who missed out
210+ # compose title
211211 cn = self .classname
212212 title = self .get (nodeid , 'title' ) or '%s message copy' % cn
213213
214+ # figure author information
214215 authid = messages .safeget (msgid , 'author' )
215216 authname = users .safeget (authid , 'realname' )
216217 if not authname :
@@ -248,7 +249,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
248249 m .append (self .email_signature (nodeid , msgid ))
249250
250251 # encode the content as quoted-printable
251- content = cStringIO .StringIO ('\n ' .join (m ))
252+ charset = getattr (self .db .config , 'EMAIL_CHARSET' , 'utf-8' )
253+ m = '\n ' .join (m )
254+ if charset != 'utf-8' :
255+ m = unicode (m , 'utf-8' ).encode (charset )
256+ content = cStringIO .StringIO (m )
252257 content_encoded = cStringIO .StringIO ()
253258 quopri .encode (content , content_encoded , 0 )
254259 content_encoded = content_encoded .getvalue ()
@@ -268,18 +273,21 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
268273 if from_tag :
269274 from_tag = ' ' + from_tag
270275
271- subject = '[%s%s] %s' % (cn , nodeid , encode_header (title ,
272- self .db .config .EMAIL_CHARSET ))
273- author = straddr ((encode_header (authname , self .db .config .EMAIL_CHARSET )
274- + from_tag , from_address ))
276+ subject = '[%s%s] %s' % (cn , nodeid , title )
277+ author = (authname + from_tag , from_address )
275278
276279 # create the message
277280 mailer = Mailer (self .db .config )
278281 message , writer = mailer .get_standard_message (sendto , subject , author )
279282
280- tracker_name = encode_header (self .db .config .TRACKER_NAME ,
281- self .db .config .EMAIL_CHARSET )
283+ # set reply-to to the tracker
284+ tracker_name = self .db .config .TRACKER_NAME
285+ if charset != 'utf-8' :
286+ tracker = unicode (tracker_name , 'utf-8' ).encode (charset )
287+ tracker_name = encode_header (tracker_name , charset )
282288 writer .addheader ('Reply-To' , straddr ((tracker_name , from_address )))
289+
290+ # message ids
283291 if messageid :
284292 writer .addheader ('Message-Id' , messageid )
285293 if inreplyto :
@@ -290,7 +298,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
290298 part = writer .startmultipartbody ('mixed' )
291299 part = writer .nextpart ()
292300 part .addheader ('Content-Transfer-Encoding' , 'quoted-printable' )
293- body = part .startbody ('text/plain; charset=utf-8' )
301+ body = part .startbody ('text/plain; charset=%s' % charset )
294302 body .write (content_encoded )
295303 for fileid in message_files :
296304 name = files .get (fileid , 'name' )
@@ -318,7 +326,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
318326 writer .lastpart ()
319327 else :
320328 writer .addheader ('Content-Transfer-Encoding' , 'quoted-printable' )
321- body = writer .startbody ('text/plain; charset=utf-8' )
329+ body = writer .startbody ('text/plain; charset=%s' % charset )
322330 body .write (content_encoded )
323331
324332 mailer .smtp_send (sendto , message )
0 commit comments