diff roundup/mailgw.py @ 1280:8b766547d4b8

store PIPE messages so we can re-send them on errors
author Richard Jones <richard@users.sourceforge.net>
date Tue, 15 Oct 2002 06:51:32 +0000
parents 6c24a86a12ae
children 284a9d6b3cf9
line wrap: on
line diff
--- a/roundup/mailgw.py	Tue Oct 15 06:49:09 2002 +0000
+++ b/roundup/mailgw.py	Tue Oct 15 06:51:32 2002 +0000
@@ -73,7 +73,7 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception. 
 
-$Id: mailgw.py,v 1.95 2002-10-07 00:52:51 richard Exp $
+$Id: mailgw.py,v 1.96 2002-10-15 06:51:32 richard Exp $
 '''
 
 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -145,8 +145,15 @@
 
     def do_pipe(self):
         ''' Read a message from standard input and pass it to the mail handler.
+
+            Read into an internal structure that we can seek on (in case
+            there's an error).
+
+            XXX: we may want to read this into a temporary file instead...
         '''
-        self.main(sys.stdin)
+        s = cStringIO.StringIO()
+        s.write(sys.stdin.read())
+        self.main(s)
         return 0
 
     def do_mailbox(self, filename):
@@ -337,8 +344,8 @@
         body = w.startbody(content_type)
         try:
             message.rewindbody()
-        except IOError:
-            body.write("*** couldn't include message body: read from pipe ***")
+        except IOError, message:
+            body.write("*** couldn't include message body: %s ***"%message)
         else:
             body.write(message.fp.read())
 

Roundup Issue Tracker: http://roundup-tracker.org/