Commit 91f91aff authored by Julien Muchembled's avatar Julien Muchembled

Make sendMailToERP5 able to not filter (ex: deliver locally)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38066 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e7d03810
...@@ -53,9 +53,18 @@ class Message(object): ...@@ -53,9 +53,18 @@ 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):
# A filter should not deliver to more than one place, otherwise we can't
# avoid duplicate (or lost) mails in case of failure.
# So this method must not be modified to allow delivery to several
# destinations. Additional deliveries (even if locally), must be done
# by the ERP5 instance itself, by activity.
if portal == 'UNAVAILABLE': if portal == 'UNAVAILABLE':
print 'Message rejected' print 'Message rejected'
sys.exit(os.EX_UNAVAILABLE) sys.exit(os.EX_UNAVAILABLE)
if portal == 'SENDMAIL':
print 'Deliver message locally ...'
os.execl('/usr/sbin/sendmail', 'sendmail', '-G', '-i',
*self.recipient_list)
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:
...@@ -84,10 +93,6 @@ class Message(object): ...@@ -84,10 +93,6 @@ class Message(object):
print 'Message ingested' print 'Message ingested'
else: else:
print 'Message dropped' 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.
# It is better to do this from the ERP5 instance itself, by activity.
class SimpleIngestionMap(object): class SimpleIngestionMap(object):
...@@ -125,10 +130,11 @@ def getOptionParser(): ...@@ -125,10 +130,11 @@ def getOptionParser():
arguments defines variables that are used by ingestion maps to determine \ arguments defines variables that are used by ingestion maps to determine \
options to send to ERP5. Currently, only 'recipient' key is used. 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 documentation of /etc/postfix/master.cf).""")
_ = parser.add_option _ = parser.add_option
_("--portal", help="URL of ERP5 instance to connect to (special value" _("--portal", help="URL of ERP5 instance to connect to, or one of the"
" 'UNAVAILABLE' means the mail is returned to the sender)") " following special values: 'UNAVAILABLE' returns the mail"
" to the sender; 'SENDMAIL' injects it back into MTA")
_("--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