Pardon the intrusion, but.....

I've searched the archives but haven't found any reference to this problem, so here it is.

We just installed v2.1 of mailman and are seeing some odd things in a few versions of Outlook and Outlook Express related to header/footer info as added by mailman. Mailman 2.0 used to eat the footer when it was a plain/html mixed e-mail, now the problem is that an e-mail composed in plain & HTML text, originally sent out as Multipart/Alternative (M/A), gets turned into Multipart/Mixed (M/M) and some versions of Outlook and OE display the footer ok, others turn it into an attachment, and yet others display it AND turn it into an attachment. I know where the code is to add the header/footer info, and understand how it works, and do know (from viewing a direct download of e-mail via telnet to pop3 server) that mailman is handling it exactly the way it was written to do it. The problem is that wrapping a new MIME type (M/M) around the original M/A type, and then adding the headers & footers to the new M/M data is causing problems with how it's interpreted by the different e-mail programs.

I have a simple solution, but don't know how to implement it. I've tried inserting new sections into the original M/A data (one new plain, one new html), but that causes loss of data in Eudora, as well as not showing up at all in Outlook 2002. The raw e-mail via telnet looks exactly like I'd expect it to, so I'm sure it's the e-mail reader that's mangling the results.

Here's my idea on how to address the problem. From what I've seen, every single mail program (and I've had people mail me from 5 diff ones so far) uses content-type: M/A for text/plain & text/html messages. What I want to do is test for multipart/alternative, append plain text header/footer to the text/plain section, and append modified header/footer with html changes to the text/html section. I'm very new to python, and haven't a clue as to how to modify the contents of each section of the multi-part data. Here's some mocked up code that shows what I think needs to be done to fix the problem.

at about line 106 of Mailman/Handlers/Decorate.py
# 03-01-18 BTM - added to handle HTML type multi-part information
elif msg.get_type() == 'multipart/alternative':
# The next easiest thing to do is prepend the header and append
# the footer to each subpart of both text/plain & text/html
# here's where I'm fuzzy on walking the list of subparts
msgplain = msg.getpart('plain')
frontsep = endsep = ''
if header and not header.endswith('\n'):
frontsep = '\n'
if footer and not oldpayload.endswith('\n'):
endsep = '\n'
newplain = header + frontsep + msgplain + endsep + footer
# again, no clue on setting it back into the msg
msg.set_part('plain', newplain)
if header:
header = '<font Face="Arial,Helvetica" Size="1">' + header.replace('\n', '<br>\n') + '</font>'
if footer:
footer = '<font Face="Arial,Helvetica" Size="1">' + footer.replace('\n', '<br>\n') + '</font></html>'
msghtml = msg.getpart('html')
# I'm aware that the case of <HTML> varies in diff e-mail apps, not sure how to overcome it (can replace be case insensitive?)
if header:
newhtml = msghtml.replace('<html>', '<html>\n' + header)
if footer:
newhtml = newhtml.replace('</html>', footer + '\n</html>')
msg.set_part('html', newhtml)
wrap = 0
# 03-01-18 BTM - end of additions

I know this won't fix 100% of the problems with mixed message types, I just found out this evening that Eudora 4.3.2 doesn't attach my signature in HTML if I attach a file. The main body of the e-mail is HTML, but the signature is in plain text, and the whole msg is M/M. If I don't attach a file, the entire message (including signature) is done in HTML & plain text just fine, and sent as M/A. I'm sure there will be some cases where it just doesn't show up on the destination mail program, but this should make it work more often than it currently does.

I've figured out python syntax pretty well, just can't figure out what methods of what objects to use to get/set the pieces of the multipart/alternative that need alteration. I'm not a python programmer, and before Saturday had never used it before, so my knowledge is limited to what I found on python.org in the reference docs.

If no-one wants to solve this directly, can someone point me in the right direction (maybe with code snippets, or source lines of code already in mailman) on how to get the contents of the text/plain (or text/html) sections of the mime data?

Does this make any sense? If not, clue me in, please!

(if this doesn't go through to the list intact, I'll re-send with the code as an attachment).

Thanks,

Brad Mettee
Baltimore, MD _______________________________________________
Mailman-Developers mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-developers

Reply via email to