Skip to content

Commit 5fca836

Browse files
author
Richard Jones
committed
bugfixes to pipe bugfix
1 parent 6c0c3b5 commit 5fca836

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

roundup/mailgw.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.96 2002-10-15 06:51:32 richard Exp $
76+
$Id: mailgw.py,v 1.97 2002-10-15 07:25:49 richard Exp $
7777
'''
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -153,6 +153,7 @@ def do_pipe(self):
153153
'''
154154
s = cStringIO.StringIO()
155155
s.write(sys.stdin.read())
156+
s.seek(0)
156157
self.main(s)
157158
return 0
158159

@@ -328,35 +329,21 @@ def bounce_message(self, message, sendto, error,
328329
body = part.startbody('text/plain')
329330
body.write('\n'.join(error))
330331

331-
# reconstruct the original message
332-
m = cStringIO.StringIO()
333-
w = MimeWriter.MimeWriter(m)
334-
# default the content_type, just in case...
335-
content_type = 'text/plain'
336-
# add the headers except the content-type
332+
# attach the original message to the returned message
333+
part = writer.nextpart()
334+
part.addheader('Content-Disposition','attachment')
335+
part.addheader('Content-Description','Message you sent')
336+
body = part.startbody('text/plain')
337337
for header in message.headers:
338-
header_name = header.split(':')[0]
339-
if header_name.lower() == 'content-type':
340-
content_type = message.getheader(header_name)
341-
elif message.getheader(header_name):
342-
w.addheader(header_name, message.getheader(header_name))
343-
# now attach the message body
344-
body = w.startbody(content_type)
338+
body.write(header)
339+
body.write('\n')
345340
try:
346341
message.rewindbody()
347342
except IOError, message:
348343
body.write("*** couldn't include message body: %s ***"%message)
349344
else:
350345
body.write(message.fp.read())
351346

352-
# attach the original message to the returned message
353-
part = writer.nextpart()
354-
part.addheader('Content-Disposition','attachment')
355-
part.addheader('Content-Description','Message you sent')
356-
part.addheader('Content-Transfer-Encoding', '7bit')
357-
body = part.startbody('message/rfc822')
358-
body.write(m.getvalue())
359-
360347
writer.lastpart()
361348
return msg
362349

0 commit comments

Comments
 (0)