[Mailman-Users] Simple notification handler

Mark Sapiro mark at msapiro.net
Wed Dec 21 17:39:15 CET 2011


Yves Moisan wrote:
>
>- Parse the Subject line looking for "*rror*"
>- If so, send an email to an arbitrary address
[...]
>
>I understand the pipeline system and how I could add the Handler for a 
>specific list, but I'm looking for a detailed Python API listing 
>somewhere to see what I can really do in the process() function, e.g.
>
>def process(mlist, msg, msgdata):
>     subject = msg.getheader('subject')
># parse subject (I'll find that) and if error
>  #  msg.send("arbitraryemail at whatever.com")


The Mailman API is documented in the source.

You need something like

import re
from Mailman import Utils
from Mailman.Message import UserNotification
NTEXT = """The text of
the
notification.
"""
NRECIP = 'recipient at example.com'
NFROM = 'sender at example.com'
NSUBJ = 'Notification subject'

def process(mlist, msg, msgdata):
    subject = Utils.oneline(msg['subject'], 'us-ascii')
    if re.search('.*rror.*', subject, re.IGNORECASE)
        nmsg = UserNotification(NRECIP, NFROM, NSUBJ, NTEXT)
        nmsg.send(mlist)


-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list