[Mailman-Users] Custom footer based on sender's email

Rob Jackson robertj at linux4free.com
Thu May 11 20:07:03 CEST 2006

I was aware of the

if not header and not footer:

And made sure that wasn't a problem.  But it seems I was probably exiting
out someplace else.  I used to be getting an error when I had it other
places, and then when I moved it to the end, the error went away, well it is
back now that I am actualy hitting the code before it exits.  Here is my
error.  Thanks for helping out with my ignorance.

"May 11 11:54:49 2006 (11951) Uncaught runner exception: global name 're' is
not defined"

What is the best way to define 're'  I have tried looking at other examples
throught the program and have been unable to determine how I need to do


-----Original Message-----
From: Mark Sapiro [mailto:msapiro at value.net] 
Sent: Thursday, May 11, 2006 11:46 AM
To: Rob Jackson; mailman-users at python.org
Subject: RE: [Mailman-Users] Custom footer based on sender's email

Rob Jackson wrote:
>Here it is.
>+++ /u1/mailman/Mailman/Handlers/Decorate.py    2006-05-10
>11:36:43.000000000 -0600
>@@ -188,6 +188,12 @@
>     del msg['content-disposition']
>     msg['Content-Type'] = 'multipart/mixed'
>+    #Testing to replace footer
>+    pl = msg.get_payload(decode=True)
>+    re.sub('AZ', 'new text', pl)
>+    msg.set_payload(pl)
> def decorate(mlist, template, what, extradict={}):

Elvis has left the building...

I.e. putting the code there will only get those messages in which the
mailman header/footer has been added as a separate mime part to a message
not already multipart/mixed.

Starting from the top of Decorate.process() we have several exits:

    # Escape hatch if both the footer and header are empty
    if not header and not footer:

If there is no defined msg_header or msg_footer, we leave.

    # If we couldn't add the header or footer in a less intrusive way, we
    # at least do it by MIME encapsulation.  We want to keep as much of the
    # outer chrome as possible.
    if not wrap:

If we have managed to add the header and/or footer to a text/plain message,
or if the message was already multipart/mixed and we added the header and/or
footer as separate mime parts, we are done and leave here.

The only thing that gets beyond here is the case where we create a new
multipart/mixed 'wrapper' with header and/or footer parts and the original
message as a message/rfc822 part.

You first have to see whether or not you have msg_header and or msg_footer
for the list, and also what the structure of the incoming message is. In the
simplest case of a single part text/plain message, you could add the three
lines just prior to

    # Escape hatch if both the footer and header are empty
    if not header and not footer:

Mark Sapiro <msapiro at value.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