[Erp5-report] r36754 jm - /erp5/trunk/products/ERP5/bin/sendMailToERP5

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jun 30 19:07:57 CEST 2010


Author: jm
Date: Wed Jun 30 19:07:57 2010
New Revision: 36754

URL: http://svn.erp5.org?rev=36754&view=rev
Log:
sendMailToERP5: add option to reject mail and print what is done

Modified:
    erp5/trunk/products/ERP5/bin/sendMailToERP5

Modified: erp5/trunk/products/ERP5/bin/sendMailToERP5
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bin/sendMailToERP5?rev=36754&r1=36753&r2=36754&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bin/sendMailToERP5 [utf8] (original)
+++ erp5/trunk/products/ERP5/bin/sendMailToERP5 [utf8] Wed Jun 30 19:07:57 2010
@@ -53,6 +53,9 @@ class Message(object):
     self.recipient_list = recipient_list
 
   def __call__(self, portal=None, **kw):
+    if portal == 'UNAVAILABLE':
+      print 'Message rejected'
+      sys.exit(os.EX_UNAVAILABLE)
     if portal is not None:
       scheme, netloc, path, query, fragment = urlparse.urlsplit(portal)
       if query or fragment:
@@ -78,6 +81,9 @@ class Message(object):
           raise
         result = e.result
       result.read() # ERP5 does not return useful information
+      print 'Message ingested'
+    else:
+      print 'Message dropped'
     # Now, we could reinject the message to postfix for local delivery,
     # using /usr/sbin/sendmail, depending on a 'sendmail' option. However,
     # we would get duplicate mails if either ERP5 or sendmail fail.
@@ -121,7 +127,8 @@ options to send to ERP5. Currently, only
 This tool can be used directly to deliver mails from postfix to ERP5, \
 by using it as a filter (cf document of /etc/postfix/master.cf).""")
   _ = parser.add_option
-  _("--portal", help="URL of ERP5 instance to connect to")
+  _("--portal", help="URL of ERP5 instance to connect to (special value"
+                     " 'UNAVAILABLE' means the mail is returned to the sender)")
   _("--user", help="use this user to connect to ERP5")
   _("--password", help="use this password to connect to ERP5")
   _("--file_name", help="ERP5 requires a file name to guess content type")




More information about the Erp5-report mailing list