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

Rob Jackson robertj at linux4free.com
Mon May 15 20:25:37 CEST 2006

Ok, I got this piece kind of working, but there is a problem with this.

This is my search and replace string, and the search at this point doesn't

pl = re.sub('lksjdfsdf', 'new text', pl)

Here is the last part of the body, it is all contained in one line:

"You received this e-mail because you are currently subscribed to this
message board alert. To unsubscribe from this alert, or to change your
settings to receive a digest version instead, please visit My Alerts."

After this message goes through mailman, this is how it comes out on the
other side:

}z?Ox^=by?m+m?y?+.n+a?Oy?zS?&~&jWZ zb
-z+i?zoz"x?v^j??3 %zl

If I add, or remove a letter to the orginal footer, anywhere, or change any
one of the punctuation marks to a letter, it will come through clean, and
not garbled.

I am stumped!


-----Original Message-----
From: mailman-users-bounces+robertj=linux4free.com at python.org
[mailto:mailman-users-bounces+robertj=linux4free.com at python.org] On Behalf
Of Mark Sapiro
Sent: Thursday, May 11, 2006 3:53 PM
To: mailman-users at python.org
Subject: Re: [Mailman-Users] Custom footer based on sender's email

Mark Sapiro wrote:

>Rob Jackson wrote:
>>+    pl = msg.get_payload(decode=True)
>>+    re.sub('AZ', 'new text', pl)
>>+    msg.set_payload(pl)
>It looks OK to me.

Actually, it's not OK. I overlooked the fact that Python strings are
immutable and re.sub doesn't (can't) change them in place. Thus,

    re.sub('AZ', 'new text', pl)

needs to be

    pl = re.sub('AZ', 'new text', pl)

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

Mailman-Users mailing list
Mailman-Users at python.org
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/

Security Policy:

More information about the Mailman-Users mailing list