[Mailman-Developers] handler to auto detach attachment and link it to a website keeping html
sylvain at opensource-expert.com
Sat Apr 19 08:57:35 CEST 2014
Thanks Mark, exactly what I need to replace with the multipart/related
Le 18/04/2014 22:30, Mark Sapiro a écrit :
> This stuff ----------------
>> clip = MIMEText(attach_clip)
>> clip.add_header('Content-Disposition', 'inline')
>> clip.add_header('Content-ID', '<part1.%d>' % 123412)
>> clip['Content-Transfer-Encoding'] = 'base64'
>> del clip['Content-type']
>> del clip['Content-transfer-encoding']
>> clip['Content-type'] = 'image/png;
>> clip['Content-transfer-encoding'] = 'base64'
> should be ---------------
> clip = MIMEImage(xxx, 'png')
Yeah, I know. But I've embedded the base64 txt data of the clip image in
the handler.py's code.
So I don't need to manage an external file for the clip. Could MIMEImage
handle internal data as well?
It seems extra effort, to mime64 decode and let MIMEImage reencode it,
Oh, great! That exactly the following code I was fighting with.
I've seen some code like that in Handlers/MimeDel.py, thanks a lot. I
wasn't able to adapt this recursive behavior.
> def fix_msg(msg):
> if msg.is_multipart():
> parts = msg.get_payload()
> # remove the next level parts, then process and reattach them
> for p in parts:
> return msg
> # process the 'leaf' parts [truncated …]
> ctype = msg.get_content_type()
> if ctype == 'text/plain' and not part['X-Mailman-Part']:
> return msg
> elif ctype == 'text/html':
> return related
More information about the Mailman-Developers