From andrew at logicalprogression.net Thu Feb 26 19:40:07 2004 From: andrew at logicalprogression.net (Andrew Veitch) Date: Thu Feb 26 19:40:12 2004 Subject: [Email-SIG] Problem with get_all Message-ID: One of our users has reported a problem with MailManager which I've traced back to the email library. He's got some very strangely formatted headers looking like this: Cc: Gsandtner Michael , "'Gsandtner Fam.'" , "'Gsandtner priv.'" And running get_all on the headers just returns one fairly mangled string. I'm not 100% sure that this is a valid format for headers but it is coming from a Microsoft client to I guess it's something we have to live with. There also seems to be a fairly excessive amount of quoting going on. The full text of the email is at: https://sourceforge.net/tracker/index.php?func=detail&aid=904033&group_id=85 788&atid=577305 By the way - is this the right place to report problems with the email library or is it better to open a ticket on the Python project? TIA Andrew From barry at python.org Thu Feb 26 21:55:07 2004 From: barry at python.org (Barry Warsaw) Date: Thu Feb 26 21:55:15 2004 Subject: [Email-SIG] Problem with get_all In-Reply-To: References: Message-ID: <1077850507.31953.45.camel@anthem.wooz.org> On Thu, 2004-02-26 at 19:40, Andrew Veitch wrote: > One of our users has reported a problem with MailManager which I've traced > back to the email library. > > He's got some very strangely formatted headers looking like this: > > Cc: Gsandtner Michael , "'Gsandtner Fam.'" > , "'Gsandtner priv.'" > > > And running get_all on the headers just returns one fairly mangled string. > > I'm not 100% sure that this is a valid format for headers but it is coming > from a Microsoft client to I guess it's something we have to live with. > There also seems to be a fairly excessive amount of quoting going on. > > The full text of the email is at: > https://sourceforge.net/tracker/index.php?func=detail&aid=904033&group_id=85 > 788&atid=577305 AFAICT, everything's working the way it's intended to work. Note that get_all() is a red herring because there's only one CC header in the message. You're getting back a list of one string element from get_all() -- you'd get just that string back from msg['cc']. First, it's the parser that groks each header and sticks the values on the Message object; it doesn't really examine the contents of the headers. So msg['cc'] is going to return the contents of the CC header of the message. You're right that there's some 'weird' quoting going on, but it's not in violation of RFC 2822 and is a perfectly legal, wrapped header. Perhaps the backslashes in the repr of the string are throwing you off? If what you want are the constituent realname/address pairs contained within the CC value, you should look at email.Utils.getaddresses(). For example, if I saved your message in /tmp/message.txt: >>> email.message_from_file(open('/tmp/message.txt')) >>> getaddresses(msg.get_all('cc')) [('Gsandtner Michael', 'gsa@adv.magwien.gv.at'), ("'Gsandtner Fam.'", 'michael.gsandtner@web.de'), ("'Gsandtner priv.'", 'michael.gsandtner@airwave.at')] which looks pretty correct to me. > By the way - is this the right place to report problems with the email > library or is it better to open a ticket on the Python project? If this were actually a bug, it would be better to open a ticket, but since there's no bug here that I can see, I suppose this SIG is a better place to post. :) Hope that helps, -Barry From andrew at logicalprogression.net Fri Feb 27 06:26:38 2004 From: andrew at logicalprogression.net (Andrew Veitch) Date: Fri Feb 27 06:27:11 2004 Subject: [Email-SIG] Problem with get_all Message-ID: Barry - thanks very much for this. I misunderstood the description of get_all. Our bug was a quoting a problem, nothing to with the library at all. MailManager uses just about every method in the email library and it's in use on about 20 sites now, some of these with very large volumes of mail and it's been rock solid. We do appreciate the work from you & the rest of the guys. A From barry at python.org Fri Feb 27 10:25:17 2004 From: barry at python.org (Barry Warsaw) Date: Fri Feb 27 10:25:21 2004 Subject: [Email-SIG] Problem with get_all In-Reply-To: References: Message-ID: <1077895516.585.55.camel@anthem.wooz.org> On Fri, 2004-02-27 at 06:26, Andrew Veitch wrote: > Barry - thanks very much for this. I misunderstood the description of > get_all. Our bug was a quoting a problem, nothing to with the library at > all. Cool. > MailManager uses just about every method in the email library and it's in > use on about 20 sites now, some of these with very large volumes of mail and > it's been rock solid. We do appreciate the work from you & the rest of the > guys. No problem! -Barry From bmunroe at tribador.net Fri Feb 27 21:20:33 2004 From: bmunroe at tribador.net (Brian Munroe) Date: Fri Feb 27 21:20:38 2004 Subject: [Email-SIG] Extending the calendar package Message-ID: I am currently developing a new module to generate and send meeting invitations to Lotus Notes R5 clients. This module basically constructs an empty text/plain email message with some strange mime headers[1] that define things like StartDateTime, Meeting Chair, etc. Additionally, I've been doing some research and it doesn't look like Python has any modules for generating/parsing/publishing in the iCal (rfc2445) format, and I thought I could eventually extend the module to support iCal in addition to Lotus Notes. I've been familarizing myself with RFCs this whole week and I am starting to go cross-eyed. I'm hoping someone can straighten me out here! Would my module be something that would eventually find it's way into the email package? Also, what about if I extended it to support iCal? Opinions welcome, thanks. -- brian [1] - Example: x-notes-item: 12/12/2004 11:20PM PST; value=300; name=StartDateTime\r\n