Geeky

The road to DevOps.

Shortening URLs in Mailman

Mailman is a great mailing list manager, and tonight I learnt how to implement my own functions.
Contrary to the FAQ, there is actually a really good way to extend the functionality of Mailman and it’s quite easy too.

Mailman uses python scripts called handlers, which are kept in mailman/Mailman/Handlers/. Each script contains a method (def, function, whatever you want to call it) called “process” which is automatically passed three arguments.

Basically in here you can do anything you would in a normal python script. The ‘msg’ variable that is actually an instance of a class which contains all of the message data (headers, body, and much other data). Once you’re done, put your new script in the above directory and add it to the GLOBAL_PIPELINE list in mailman/Mailman/mm_cfg.py (this file gets default from Defaults.py, copy anything you need from Defaults.py and put it in mm_cfg.py).
If you’re interested in doing any hacking of messages, look at Decorate.py in the above directory. I was able to make a very simple but effective URL shortener. Every message sent to my mailing lists now gets saved to a database and a new shorter URL is put after the original. If anyone would like to see the code, let me know 🙂

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.