comparison roundup/roundupdb.py @ 4225:7baf1925c4c1

fix construction of individual messages to nosy recipents with attachments
author Richard Jones <richard@users.sourceforge.net>
date Mon, 20 Jul 2009 06:24:52 +0000
parents d5cd6f440396
children 7275e3dec0e0
comparison
equal deleted inserted replaced
4224:3f6cadb98c2f 4225:7baf1925c4c1
370 370
371 # figure the encoding 371 # figure the encoding
372 charset = getattr(self.db.config, 'EMAIL_CHARSET', 'utf-8') 372 charset = getattr(self.db.config, 'EMAIL_CHARSET', 'utf-8')
373 373
374 # construct the content and convert to unicode object 374 # construct the content and convert to unicode object
375 content = unicode('\n'.join(m), 'utf-8').encode(charset) 375 body = unicode('\n'.join(m), 'utf-8').encode(charset)
376 376
377 # make sure the To line is always the same (for testing mostly) 377 # make sure the To line is always the same (for testing mostly)
378 sendto.sort() 378 sendto.sort()
379 379
380 # make sure we have a from address 380 # make sure we have a from address
457 message['In-Reply-To'] = inreplyto 457 message['In-Reply-To'] = inreplyto
458 458
459 # attach files 459 # attach files
460 if message_files: 460 if message_files:
461 # first up the text as a part 461 # first up the text as a part
462 part = MIMEText(content) 462 part = MIMEText(body)
463 encode_quopri(part) 463 encode_quopri(part)
464 message.attach(part) 464 message.attach(part)
465 465
466 for fileid in message_files: 466 for fileid in message_files:
467 name = files.get(fileid, 'name') 467 name = files.get(fileid, 'name')
492 Encoders.encode_base64(part) 492 Encoders.encode_base64(part)
493 part['Content-Disposition'] = 'attachment;\n filename="%s"'%name 493 part['Content-Disposition'] = 'attachment;\n filename="%s"'%name
494 message.attach(part) 494 message.attach(part)
495 495
496 else: 496 else:
497 message.set_payload(content) 497 message.set_payload(body)
498 encode_quopri(message) 498 encode_quopri(message)
499 499
500 if first: 500 if first:
501 mailer.smtp_send(sendto + bcc_sendto, message.as_string()) 501 mailer.smtp_send(sendto + bcc_sendto, message.as_string())
502 else: 502 else:

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