[Mailman-Developers] modifying payload using same encoding and Content-Transfer-Encoding

Sylvain Viart sylvain at opensource-expert.com
Mon May 12 18:03:44 CEST 2014


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


More information about the Mailman-Developers mailing list