Re: [Mailman-Users] handler to auto detach attachment and link it to a website keeping html
On 04/15/2014 09:08 AM, Sylvain Viart wrote: 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 in order to replace an attachment with a dummy text file containing the link? It isn't really important in this case, but 'msg' is a Mailman.Message.Message instance. Mailman.Message.Message is a subclass of email.message.Message, but it mostly just adds a few methods. It doesn't change the behavior of any methods documented at https://docs.python.org/2/library/email.html. You can use code like the above to manipulate the sub-part headers, but No other way to, remove all header in oneshot, or replace with a fresh parsed attachment? if you wish to remove the subpart all together you can just 'del' it and use methods documented at https://docs.python.org/2/library/email.mime.html to create new sub-parts and use the Message.attach() method to attach them. But I will publish the source. Is there a preferred repository or procedure? Yes. This will change in the future, but the preferred method is to create a bzr branch containing your change, register at launchpad and then push your branch to https://code.launchpad.net/mailman. But whatever you do, post a note here so we know. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website keeping html
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.htmlhttps://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. -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
On 04/11/2014 02:06 PM, Mark Sapiro wrote: Development question, is there a way to test the handler against a mail content, outside of the full mailman context? Something like: $ python -some-useful-switch-here MyHandler.py mymail_withheader.txt withlist is the tool for this. When I get a chance, I will update the above FAQ with a skeleton framework, but in short you need a withlist script that imports your handler, reads your message and builds a Mailman.Message.Message object and calls your handler's process function. I have created a test script at http://www.msapiro.net/scripts/test_handler.py (mirrored at http://fog.ccsf.cc.ca.us/~msapiro/scripts/test_handler.py) which can be used to unit test your handler against a test list and message and optional metadata. I also updated the FAQ at http://wiki.list.org/x/l4A9 to point to this script. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Hi, Le 28/03/2014 16:58, Mark Sapiro a écrit : As it says in that post, scrub_nondigest is an all or nothing feature. I may code the behavior I've described for my need : Detaching attachment, storing, linking back into the original mail. 4.67. How do I implement a custom handler in Mailman http://wiki.list.org/pages/viewpage.action?pageId=4030615 Following instruction here, I've started to develop my custom handler, as Scrubber is scrubbing too strong for my purpose. Development question, is there a way to test the handler against a mail content, outside of the full mailman context? Something like: $ python -some-useful-switch-here MyHandler.py mymail_withheader.txt Is it more appropriate to post such question to mailman-developers list? I've found: http://pythonhosted.org/mailman/src/mailman/docs/DEVELOP.html Regards, Sylvain. -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
On 04/11/2014 08:54 AM, Sylvain Viart wrote: 4.67. How do I implement a custom handler in Mailman http://wiki.list.org/pages/viewpage.action?pageId=4030615 Following instruction here, I've started to develop my custom handler, as Scrubber is scrubbing too strong for my purpose. Development question, is there a way to test the handler against a mail content, outside of the full mailman context? Something like: $ python -some-useful-switch-here MyHandler.py mymail_withheader.txt withlist is the tool for this. When I get a chance, I will update the above FAQ with a skeleton framework, but in short you need a withlist script that imports your handler, reads your message and builds a Mailman.Message.Message object and calls your handler's process function. Is it more appropriate to post such question to mailman-developers list? Either is OK. I've found: http://pythonhosted.org/mailman/src/mailman/docs/DEVELOP.html That's for Mailman 3 and isn't relevant to Mailman 2.1.x. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Sylvain Viart writes: Development question, is there a way to test the handler against a mail content, outside of the full mailman context? I forget the exact incantation, but I have a test list, and just test for the test list at the top of the Handler, and return success immediately. Something like: $ python -some-useful-switch-here MyHandler.py mymail_withheader.txt It's not going to be that easy because the handlers receive both the message itself and a message information object, and creation of the object is non-trivial. For hints I'd look at the testing code. Is it more appropriate to post such question to mailman-developers list? Not as far as I'm concerned, create a custom Handler is commonly offered as a solution here, so we should be willing to support it here. -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Hi, Thanks for the information. In fact, topics I've found about scrubbing, or detaching attachment, are pretty old, related to computer science… That's why I'm asking for fresh 2014 confirmation. :-) Le 28/03/2014 16:58, Mark Sapiro a écrit : As it says in that post, scrub_nondigest is an all or nothing feature. There is no current mechanism for scrubbing only those attachments greater than a given size. Hum, I will experiment it. I may code the behavior I've described for my need : Detaching attachment, storing, linking back into the original mail. Which is supposed to be already mostly part of Scrubber.py handler. I will probably requiring coding help, as I'm python new-bee (yes, a voluntary honey gift 8-) ). 4.82 How do I filter or scrub content before checking if a message is too big? http://wiki.list.org/pages/viewpage.action?pageId=7602227 Is it related to archiving only, or does it perform what I've described? That FAQ is about applying content filtering and/or scrubbing before testing the message for a too big hold. It does nothing about only scrubbing attachments over some size. Is it not the same goal? If you switch the order. Big attachment will be scrubbed so the message wont be too big anymore. Oh, you're right I see… You mean you cant select the size of the attachment which will be detached by the scrubbing process. All attachment will be detached, no size checking. I will let you informed. Regards, Sylvain. -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Hi Mark, Le 26/03/2014 20:32, Mark Sapiro a écrit : My question is: Is there any handler that I can setup in the pipeline to: * detach an attachment * post it to a webservice (or run a script uploading it to an online storage) * modify the content of the mail, linking it to the online stored attachment How about just setting the list's web admin Non-digest options - scrub_nondigest to Yes. I've also found this option here, I didn't notice it before. Any attachments larger than that size, I'd like to be scrubbed and a link url inserted https://mail.python.org/pipermail/mailman-users/2010-July/069955.html 4.82 How do I filter or scrub content before checking if a message is too big? http://wiki.list.org/pages/viewpage.action?pageId=7602227 Is it related to archiving only, or does it perform what I've described? I didn't know that word 'scrub', it's used in the meaning of deep washing, right? I must specify, is that the web server hosting the detached part of the message, will probably be a different server that the one hosting the mailman. I may start to look at the code of Mailman/Handlers/Scrubber.py, right? Thanks pointing me on this feature. Regards, Sylvain. -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Could someone please tell me which manual this scrub_nondigest option is described in? I didn't know mailman could do this. Sent from my iPad On 27 Mar 2014, at 5:33 am, Mark Sapiro m...@msapiro.net wrote: Sylvain Viart wrote: My question is: Is there any handler that I can setup in the pipeline to: * detach an attachment * post it to a webservice (or run a script uploading it to an online storage) * modify the content of the mail, linking it to the online stored attachment How about just setting the list's web admin Non-digest options - scrub_nondigest to Yes. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/pshute%40nuw.org.au -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
On 03/27/2014 11:31 PM, Sylvain Viart wrote: Le 26/03/2014 20:32, Mark Sapiro a écrit : How about just setting the list's web admin Non-digest options - scrub_nondigest to Yes. I've also found this option here, I didn't notice it before. Any attachments larger than that size, I'd like to be scrubbed and a link url inserted https://mail.python.org/pipermail/mailman-users/2010-July/069955.html As it says in that post, scrub_nondigest is an all or nothing feature. There is no current mechanism for scrubbing only those attachments greater than a given size. 4.82 How do I filter or scrub content before checking if a message is too big? http://wiki.list.org/pages/viewpage.action?pageId=7602227 Is it related to archiving only, or does it perform what I've described? That FAQ is about applying content filtering and/or scrubbing before testing the message for a too big hold. It does nothing about only scrubbing attachments over some size. I didn't know that word 'scrub', it's used in the meaning of deep washing, right? Essentially, yes. I must specify, is that the web server hosting the detached part of the message, will probably be a different server that the one hosting the mailman. The scrubber stores attachments in the list's archive which is normally on the Mailman server. If you want them stored elsewhere, you should probably look at a custom handler to do the scrubbing and also to only scrub attachments over some size. I may start to look at the code of Mailman/Handlers/Scrubber.py, right? Right. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
On 03/28/2014 07:06 AM, Peter Shute wrote: Could someone please tell me which manual this scrub_nondigest option is described in? I didn't know mailman could do this. It should be documented in the List Administrator's Manual http://wiki.list.org/display/DOC/Mailman+2.1+List+Administrators+Manual, but that manual is incomplete and it's not there. The only documentation is in the web admin GUI on the Non-digest options page at the (Details for scrub_nondigest) link. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
[Mailman-Users] handler to auto detach attachment and link it to a website?
Hi, I've a project to setup a mailman for newsletter. I've found many interesting links about it. I will post them as a reminder at the end of this message, as it can help someone else. My question is: Is there any handler that I can setup in the pipeline to: * detach an attachment * post it to a webservice (or run a script uploading it to an online storage) * modify the content of the mail, linking it to the online stored attachment ? Or a good base to program it. The goal to achieve, is to permit restricted sender to write mail with attachment but do not replicate it to all member of the list. Also for non technical writer, uploading the attachment and linking may be too painful. Regards, Sylvain. Reference links, some may be pretty old. newsletter : How do I create a newsletter/announcement/one-way list? http://wiki.list.org/pages/viewpage.action?pageId=4030685 personalisation VERP exemple de mail, simple piste : https://mail.python.org/pipermail/mailman-users/2003-February/026008.html 4.48. How can I change the HTML (or .txt) templates used by my mailing lists? http://wiki.list.org/pages/viewpage.action?pageId=4030605 4.33. How do I put a subscribe form for my list on a web page? http://wiki.list.org/pages/viewpage.action?pageId=4030596 3.40. I want to completely customize the look and feel of Mailman – how do I do that? http://wiki.list.org/pages/viewpage.action?pageId=4030560 What is the largest list Mailman can run? http://wiki.list.org/pages/viewpage.action?pageId=4030518 [Mailman-Users] Keeping the Publich_HTML subscription page from popping up. http://www.mail-archive.com/mailman-users%40python.org/msg24296.html [Mailman-Users] Editing confirm page http://www.mail-archive.com/mailman-users%40python.org/msg32261.html Mailman processes incoming messages through a pipeline of handlers which each do parts of the message processing http://wiki.list.org/pages/viewpage.action?pageId=7602227 -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
Re: [Mailman-Users] handler to auto detach attachment and link it to a website?
Sylvain Viart wrote: My question is: Is there any handler that I can setup in the pipeline to: * detach an attachment * post it to a webservice (or run a script uploading it to an online storage) * modify the content of the mail, linking it to the online stored attachment How about just setting the list's web admin Non-digest options - scrub_nondigest to Yes. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org