[Mailman-Users] handler to auto detach attachment and link it to a website keeping html

Sylvain Viart sylvain at opensource-expert.com
Tue Apr 15 18:08:46 CEST 2014


Hi,

Le 13/04/2014 17:55, Mark Sapiro a écrit :
>> withlist is the tool for this. +
>> http://www.msapiro.net/scripts/test_handler.py
> I also updated the FAQ at <http://wiki.list.org/x/l4A9> to point to this script.

Thanks, it saves me a lot of re-testing boring emails. Especially useful 
as I never programmed in Python before.
And I do perform some SyntaxError!

I borrowed a code from Mailman/Handlers/MimeDel.py

def reset_payload(msg, txt, fname, url):
     # Reset payload of msg to contents of subpart, and fix up content 
headers
     msg.set_payload(txt)
     del msg['content-type']
     del msg['content-transfer-encoding']
     del msg['content-disposition']
     del msg['content-description']

     msg.add_header('X-Mailman-Part', 'Attachment-moved', url=url)
     msg.add_header('Content-Type', 'text/plain', charset='UTF-8', 
name=fname)
     msg.add_header('Content-Transfer-Encoding', '8bit')
     msg.add_header('Content-Disposition', 'attachment', filename=fname)
     msg.add_header('Content-Description', "Attachment-moved by Mailman")


Is it the correct way to use email.message.Message 
<https://docs.python.org/2/library/email.message.html><https://docs.python.org/2/library/email.message.html> 
in order to replace an attachment with a dummy text file containing the 
link?

No other way to, remove all header in oneshot, or replace with a fresh 
parsed attachment?

A thunderbird Filelink 
<https://support.mozilla.org/en-US/kb/filelink-large-attachments> 
extension produced for example:

    X-Mozilla-Cloud-Part: cloudFile; url=http://ovh.to/someurl;
    name=crazy_heavy_to_much.pdf
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: 7bit


I took this behavior and started to develop some parts.
I will limit the feature to my own context, not covering all case of mix 
of nested part attached…
But I will publish the source.

Is there a preferred repository or procedure?
Or is it ok to push it on git hub?

Regards,
Sylvain.



More information about the Mailman-Users mailing list