Hi, I have a script that is invoked by .forward on a Unix mailbox.
It works fine parsing an attachment and saving to disk when the email is sent directly to the email address (header 1), but doesn't work when the email is sent via a majordomo mailing list (header 2). I've looked at the mime files coming into mail, and they look the same. I've attached the headers, and I don't see any major different, although there is a warning on the mailing list that "X-Authentication- Warning: lists...: pmx set sender to [EMAIL PROTECTED] using -f". Here is the code fragment, it seems to fail on the second header on the part.get_param call: parser=email.Parser.Parser() msg = parser.parsestr(raw_email) counter = 1 for part in msg.walk(): if part.get_main_type()== 'multipart': continue log.write("gets here") #gets to this point for majordomo send filename = part.get_param("name") log.write("...but not here") #but not to this point if filename==None: filename = "part-%1" % counter counter += 1 fp = open(os.path.join(dir, filename), 'wb') fp.write(part.get_payload(decode=1)) fp.close() ============================= Header 1 ============================= >From [EMAIL PROTECTED] Mon Jul 7 11:00:46 2008 Received: from nospam3... by mail... with ESMTP id m67I0jSg023687 for <[EMAIL PROTECTED]; Mon, 7 Jul 2008 11:00:45 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) Received: from exch-mail... by nospam... with ESMTP id m67I0jfd014416 for <[EMAIL PROTECTED]>; Mon, 7 Jul 2008 11:00:45 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: application/vnd.ms-excel; name="po_test.xls" Content-Transfer-Encoding: base64 Content-Description: po_test.xls Content-Disposition: attachment; filename="po_test.xls" Subject: test case Date: Mon, 7 Jul 2008 11:00:44 -0700 Message-ID: <[EMAIL PROTECTED]> In-Reply-To: <[EMAIL PROTECTED]> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: test case thread-index: AcjgWxsfx8N1mNqFSOq9C/j/8FIZIQAADqBg References: <[EMAIL PROTECTED]> From: "Shab, Theodore" <[EMAIL PROTECTED]> To: "arf" <[EMAIL PROTECTED]> Content-Length: 18675 Status: RO ============================= Header 2 ============================= >From [EMAIL PROTECTED] Mon Jul 7 11:01:05 2008 Received: from list... (list...) by mail with ESMTP id m67I14uL023715; Mon, 7 Jul 2008 11:01:04 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) Received: from lists... by list... with ESMTP id m67I13bD017476 for <[EMAIL PROTECTED]>; Mon, 7 Jul 2008 11:01:03 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) Received: (from [EMAIL PROTECTED]) by list.../Submit) id m67I13lG017475 for list-report-outgoing; Mon, 7 Jul 2008 11:01:03 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) X-Authentication-Warning: lists...: pmx set sender to owner-list- [EMAIL PROTECTED] using -f Received: from nospam... (nospam...) by lists... with ESMTP id m67I127h017471 for <[EMAIL PROTECTED]>; Mon, 7 Jul 2008 11:01:02 -0700 (PDT) (envelope-from [EMAIL PROTECTED]) Received: from exch-mai...) by nospam... with ESMTP id m67I11g2014193 for <[EMAIL PROTECTED]>; Mon, 7 Jul 2008 11:01:02 -0700 (envelope-from [EMAIL PROTECTED]) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: application/vnd.ms-excel; name="po_test.xls" Content-Transfer-Encoding: base64 Content-Description: po_test.xls Content-Disposition: attachment; filename="po_test.xls" Subject: test case 2 Date: Mon, 7 Jul 2008 11:01:01 -0700 Message-ID: <[EMAIL PROTECTED]> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: test case 2 thread-index: AcjgW2qv6AWa1eUxTXGlSQ5a2g7OuA== From: "Shab, Theodore" <[EMAIL PROTECTED]> To: "list-report" <[EMAIL PROTECTED]> Sender: [EMAIL PROTECTED] Precedence: bulk Content-Length: 18675 Status: O -- http://mail.python.org/mailman/listinfo/python-list