[Mailman-Users] Personalization in the original email

Mark Sapiro msapiro at value.net
Tue Mar 28 18:52:18 CEST 2006

fmpage at free.fr wrote:
>I've been trying to get personalization working inside the body of the original
>email instead of using header and footer.
>I did manage to get it working in plain text and html format, by doing some
>tweaking in the Decorate.py file.
>However, the code I added to get it working for multipart/alternative does not
>seem to work. See below:
>msgtype = msg.get_content_type()
>if not msg.is_multipart():
>   sMsgToFormat=msg.get_payload()
>elif msgtype == 'multipart/alternative':
>   sBoundary=msg.get_boundary()
>   part=msg.get_payload()
>   for val in part:
>      sPart=sBoundary+'\n'+val.as_string()
>      sMsgToFormat+=sPart
>   sMsgToFormat+='\n'
>#now replace substitute var that are formmated as [[variable]]
>for key, val in d.iteritems():
>   sMsgToFormat=string.replace(sMsgToFormat,'[['+key+']]',val)
>#set the original message with the new content
>The output generated seems ok when I look at the mail source on any client, but
>the message does not show up at all.

First, this is probably OT for mailman-users. I suggest you take any
follow ups to mailman-developers.

You have probably broken the MIME structure in some way. It is not
clear to me exactly how, but you are manipulating MIME parts outside
of the standard methods for doing so, so it's not surprising. Why not
just to something like:

    for part in msg.walk():
        if part.get_content_maintype() == 'text':
            del part['content-transfer-encoding']

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