tale of two attachments

T

TBS

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 owner-list-report@... 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 tshab@... Mon Jul 7 11:00:46 2008
Received: from nospam3...
by mail... with ESMTP id m67I0jSg023687
for <direct@...; Mon, 7 Jul 2008 11:00:45 -0700 (PDT)
(envelope-from tshab@whatever)
Received: from exch-mail...
by nospam... with ESMTP id m67I0jfd014416
for <direct@whatever>; Mon, 7 Jul 2008 11:00:45 -0700 (PDT)
(envelope-from tshab@...)
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: <CFF3D7191F21B44FA906AAE979C66AEA022AFACC@...>
In-Reply-To: <CFF3D7191F21B44FA906AAE979C66AEA022AFACB@...>
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
Thread-Topic: test case
thread-index: AcjgWxsfx8N1mNqFSOq9C/j/8FIZIQAADqBg
References: <CFF3D7191F21B44FA906AAE979C66AEA022AFACB@exch-mail...>
From: "Shab, Theodore" <tshab@...>
To: "arf" <direct@...>
Content-Length: 18675
Status: RO

=============================
Header 2
=============================

From owner-list-report@... 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 owner-list-report@...)
Received: from lists...
by list... with ESMTP id m67I13bD017476
for <list-report-outgoing@...>; Mon, 7 Jul 2008 11:01:03 -0700 (PDT)
(envelope-from owner-list-report@...)
Received: (from pmx@localhost)
by list.../Submit) id m67I13lG017475
for list-report-outgoing; Mon, 7 Jul 2008 11:01:03 -0700 (PDT)
(envelope-from owner-list-report@...)
X-Authentication-Warning: lists...: pmx set sender to owner-list-
report@... using -f
Received: from nospam... (nospam...)
by lists... with ESMTP id m67I127h017471
for <list-report@...>; Mon, 7 Jul 2008 11:01:02 -0700 (PDT)
(envelope-from tshab@...)
Received: from exch-mai...)
by nospam... with ESMTP id m67I11g2014193
for <list-report@...>; Mon, 7 Jul 2008 11:01:02 -0700
(envelope-from tshab@...)
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: <CFF3D7191F21B44FA906AAE979C66AEA022AFACD@...>
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
Thread-Topic: test case 2
thread-index: AcjgW2qv6AWa1eUxTXGlSQ5a2g7OuA==
From: "Shab, Theodore" <tshab@...>
To: "list-report" <list-report@...>
Sender: owner-list-report@...
Precedence: bulk
Content-Length: 18675
Status: O
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top