Commit 8d30c714 authored by Julien Muchembled's avatar Julien Muchembled

sendMailToERP5: add option to reject mail and print what is done

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36754 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6d2570d
...@@ -53,6 +53,9 @@ class Message(object): ...@@ -53,6 +53,9 @@ class Message(object):
self.recipient_list = recipient_list self.recipient_list = recipient_list
def __call__(self, portal=None, **kw): def __call__(self, portal=None, **kw):
if portal == 'UNAVAILABLE':
print 'Message rejected'
sys.exit(os.EX_UNAVAILABLE)
if portal is not None: if portal is not None:
scheme, netloc, path, query, fragment = urlparse.urlsplit(portal) scheme, netloc, path, query, fragment = urlparse.urlsplit(portal)
if query or fragment: if query or fragment:
...@@ -78,6 +81,9 @@ class Message(object): ...@@ -78,6 +81,9 @@ class Message(object):
raise raise
result = e.result result = e.result
result.read() # ERP5 does not return useful information 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, # Now, we could reinject the message to postfix for local delivery,
# using /usr/sbin/sendmail, depending on a 'sendmail' option. However, # using /usr/sbin/sendmail, depending on a 'sendmail' option. However,
# we would get duplicate mails if either ERP5 or sendmail fail. # we would get duplicate mails if either ERP5 or sendmail fail.
...@@ -121,7 +127,8 @@ options to send to ERP5. Currently, only 'recipient' key is used. ...@@ -121,7 +127,8 @@ options to send to ERP5. Currently, only 'recipient' key is used.
This tool can be used directly to deliver mails from postfix to ERP5, \ 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).""") by using it as a filter (cf document of /etc/postfix/master.cf).""")
_ = parser.add_option _ = 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") _("--user", help="use this user to connect to ERP5")
_("--password", help="use this password 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") _("--file_name", help="ERP5 requires a file name to guess content type")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment