On 05/12/2014 09:03 AM, Sylvain Viart wrote: > > I don't manage to figure out how to keep the same > Content-Transfer-Encoding, while rewriting the content?
Do you really want that? That's not what your example code does. > msg.set_payload() doesn't seems to trigger any encoding, base64 for > example was set. It will if there is a charset parameter and the message contains no Content-Transfer-Encoding: header. See <https://docs.python.org/2/library/email.message.html#email.message.Message.set_payload> and the implicit <https://docs.python.org/2/library/email.message.html#email.message.Message.set_charset>. > not using decode=True, return a base64 bloc… I just want to write it back. > I should be able to know that the payload was encoded… > > > related = MIMEMultipart('related') > > html_footer = HTML_ATTACHMENT_HOLDER % {'HTML_HERE': > html_attach} > html_footer += '</body>' > old_content = msg.get_payload(decode=True) > new_content = re.sub(r'</body>', html_footer, old_content) > if old_content != new_content: > syslog('debug', 'add html footer') > else: > syslog('debug', 'no html footer added') > > charset = msg.get_content_charset() > syslog('debug', 'get_content_charset: %s, > Content-Transfer-Encoding: %s', charset, msg['Content-Transfer-Encoding']) > Here, add del msg['content-transfer-encoding'] Don't delete Content-Type or it will get set to text/plain. > msg.set_payload(new_content, charset) > related.attach(msg) > related.attach(clip_payload) > > > The output produced must be wrong: ... -- Mark Sapiro <[email protected]> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan _______________________________________________ Mailman-Developers mailing list [email protected] https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
