Hi,

I don't manage to figure out how to keep the same Content-Transfer-Encoding, while rewriting the content?

msg.set_payload() doesn't seems to trigger any encoding, base64 for example was set.

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'])

            msg.set_payload(new_content, charset)
            related.attach(msg)
            related.attach(clip_payload)


The output produced must be wrong:

Content-Transfer-Encoding: base64
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">

sysloged output:
May 12 17:45:32 2014 (1795) get_content_charset: utf-8, Content-Transfer-Encoding: base64
_______________________________________________
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

Reply via email to