Code

Removed generation of change note from "sendmessage" in roundupdb.py.
[roundup.git] / roundup-mailgw
index f0342d396b0613b61083e4ee3fda43cdf3a6ef89..9e3a006ae3ce9c2e8cd62cad0062883898551940 100755 (executable)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundup-mailgw,v 1.12 2001-11-08 05:16:55 richard Exp $
+# $Id: roundup-mailgw,v 1.17 2001-12-02 05:06:16 richard Exp $
 
-import sys, os, re
-if int(sys.version[0]) < 2:
-    print "Roundup requires Python 2.0 or newer."
+import sys, os, re, cStringIO
+if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1):
+    print "Roundup requires Python 2.1 or newer."
     sys.exit(1)
 
-from mimetools import Message
+from roundup.mailgw import Message
 
 def do_pipe(handler):
     '''Read a message from standard input and pass it to the mail handler.
@@ -73,11 +73,20 @@ def do_pop(handler, server, user='', password=''):
     server.user(user)
     server.pass_(password)
     numMessages = len(server.list()[1])
-    for i in range(numMessages):
-        for j in server.retr(i+1)[1]:
-            s = cStringIO.StringIO('\n'.join(j))
-            s.seek(0)
-            handler.handle_Message(Message(s))
+    for i in range(1, numMessages+1):
+        # retr: returns 
+        # [ pop response e.g. '+OK 459 octets',
+        #   [ array of message lines ],
+        #   number of octets ]
+        lines = server.retr(i)[1]
+        s = cStringIO.StringIO('\n'.join(lines))
+        s.seek(0)
+        handler.handle_Message(Message(s))
+        # delete the message
+        server.dele(i)
+
+    # quit the server to commit changes.
+    server.quit()
     return 0
 
 def usage(args, message=None):
@@ -131,7 +140,7 @@ def main(args):
 
     # get a mail handler
     db = instance.open('admin')
-    handler = instance.MailGW(db)
+    handler = instance.MailGW(instance, db)
 
     # if there's no more arguments, read a single message from stdin
     if len(args) == 2:
@@ -159,6 +168,25 @@ if __name__ == '__main__':
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.16  2001/11/30 18:23:55  jhermann
+# Cleaned up strange import (less pollution, too)
+#
+# Revision 1.15  2001/11/30 13:16:37  rochecompaan
+# Fixed bug. Mail gateway was not using the extended Message class
+# resulting in failed submissions when mails were processed from a Unix
+# mailbox
+#
+# Revision 1.14  2001/11/13 21:44:44  richard
+#  . re-open the database as the author in mail handling
+#
+# Revision 1.13  2001/11/09 01:05:55  richard
+# Fixed bug #479511 ] mailgw to pop once engelbert gruber tested the POP
+# gateway.
+#
+# Revision 1.12  2001/11/08 05:16:55  richard
+# Rolled roundup-popgw into roundup-mailgw. Cleaned mailgw up significantly,
+# tested unix mailbox some more. POP still untested.
+#
 # Revision 1.11  2001/11/07 05:32:58  richard
 # More roundup-mailgw usage help.
 #