summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2000-06-05 15:54:47 +0000
committerbwarsaw2000-06-05 15:54:47 +0000
commitc2c6f9c24c7ea40a4a3eddf263093e586ae838ed (patch)
tree842ff30c70e5b7d67582bd46f45071e0650c736a
parentfb469cad2ba6040d9c942eeb62ba769ce365d585 (diff)
downloadmailman-c2c6f9c24c7ea40a4a3eddf263093e586ae838ed.tar.gz
mailman-c2c6f9c24c7ea40a4a3eddf263093e586ae838ed.tar.zst
mailman-c2c6f9c24c7ea40a4a3eddf263093e586ae838ed.zip
-rw-r--r--Mailman/Bouncers/BouncerAPI.py19
-rw-r--r--Mailman/Bouncers/Caiwireless.py2
-rw-r--r--Mailman/Bouncers/Catchall.py10
-rw-r--r--Mailman/Bouncers/DSN.py2
-rw-r--r--Mailman/Bouncers/Exim.py2
-rw-r--r--Mailman/Bouncers/Netscape.py87
-rw-r--r--Mailman/Bouncers/Postfix.py2
-rw-r--r--Mailman/Bouncers/Qmail.py2
-rw-r--r--Mailman/Bouncers/Smail.py2
-rw-r--r--Mailman/Bouncers/Yahoo.py2
10 files changed, 107 insertions, 23 deletions
diff --git a/Mailman/Bouncers/BouncerAPI.py b/Mailman/Bouncers/BouncerAPI.py
index 340cc896e..0415df9a4 100644
--- a/Mailman/Bouncers/BouncerAPI.py
+++ b/Mailman/Bouncers/BouncerAPI.py
@@ -41,22 +41,24 @@ def ScanMessages(mlist, msg, testing=0):
'Caiwireless',
'Smail',
'Exim',
+ 'Netscape',
'Catchall',
]
for modname in pipeline:
mod = __import__('Mailman.Bouncers.'+modname)
func = getattr(getattr(getattr(mod, 'Bouncers'), modname), 'process')
- addrs = func(mlist, msg)
+ addrs = func(msg)
if addrs:
for addr in addrs:
# we found a bounce or a list of bounce addrs
if not testing:
mlist.RegisterBounce(addr, msg)
else:
- print ' Bounce of %s detected by module %s' % (
- addr, modname)
+ print '%16s: detected address <%s>' % (modname, addr)
# we saw some bounces
return 1
+ elif testing:
+ print '%16s: no bounces detected' % modname
# no bounces detected
return 0
@@ -73,15 +75,12 @@ if __name__ == '__main__':
print msg
sys.exit(code)
- if len(sys.argv) < 3:
- usage(1, 'required arguments: <list> <file> [, <file> ...]')
+ if len(sys.argv) < 2:
+ usage(1, 'required arguments: <file> [, <file> ...]')
- listname = sys.argv[1]
- mlist = MailList.MailList(listname, lock=0)
-
- for filename in sys.argv[2:]:
+ for filename in sys.argv[1:]:
print 'scanning file', filename
fp = open(filename)
msg = mimetools.Message(fp)
- ScanMessages(mlist, msg, testing=1)
+ ScanMessages(None, msg, testing=1)
fp.close()
diff --git a/Mailman/Bouncers/Caiwireless.py b/Mailman/Bouncers/Caiwireless.py
index c519520fd..bed6a7902 100644
--- a/Mailman/Bouncers/Caiwireless.py
+++ b/Mailman/Bouncers/Caiwireless.py
@@ -25,7 +25,7 @@ acre = re.compile(r'<(?P<addr>[^>]*)>')
-def process(mlist, msg):
+def process(msg):
if msg.gettype() <> 'multipart/mixed':
return None
# this format thinks it's a MIME but it really isn't
diff --git a/Mailman/Bouncers/Catchall.py b/Mailman/Bouncers/Catchall.py
index 2ce0b1512..41c6ee437 100644
--- a/Mailman/Bouncers/Catchall.py
+++ b/Mailman/Bouncers/Catchall.py
@@ -25,10 +25,12 @@ import regsub
import regex
from types import StringType
+from Mailman import mm_cfg
+
# Return 0 if we couldn't make any sense of it, 1 if we handled it.
-def process(mlist, msg):
+def process(msg):
candidates = []
# See Mailman.Message.GetSender :(
sender = msg.get('sender')
@@ -48,7 +50,7 @@ def process(mlist, msg):
remote_host = who_info[at_index+1:]
else:
who_from = who_info
- remote_host = mlist.host_name
+ remote_host = mm_cfg.DEFAULT_HOST_NAME
if not who_from in ['mailer-daemon', 'postmaster', 'orphanage',
'postoffice', 'ucx_smtp', 'a2']:
return 0
@@ -176,10 +178,6 @@ def process(mlist, msg):
# Use stuff after open angle and before (optional) close:
who = regsub.splitx(who[1:], ">")[0]
if who not in did:
-## if action == REMOVE:
-## mlist.HandleBouncingAddress(who, msg)
-## else:
-## mlist.RegisterBounce(who, msg)
did.append(who)
## return message_grokked
return did
diff --git a/Mailman/Bouncers/DSN.py b/Mailman/Bouncers/DSN.py
index a685fa6ea..086890d91 100644
--- a/Mailman/Bouncers/DSN.py
+++ b/Mailman/Bouncers/DSN.py
@@ -38,7 +38,7 @@ def parseaddr(val):
-def process(mlist, msg):
+def process(msg):
if msg.gettype() <> 'multipart/report' or \
msg.getparam('report-type') <> 'delivery-status':
# then
diff --git a/Mailman/Bouncers/Exim.py b/Mailman/Bouncers/Exim.py
index 5dd955662..604b52b02 100644
--- a/Mailman/Bouncers/Exim.py
+++ b/Mailman/Bouncers/Exim.py
@@ -22,7 +22,7 @@ an `addresslist' of failed addresses.
"""
-def process(mlist, msg):
+def process(msg):
addrs = []
for fullname, addr in msg.getaddrlist('x-failed-recipients'):
addrs.append(addr)
diff --git a/Mailman/Bouncers/Netscape.py b/Mailman/Bouncers/Netscape.py
new file mode 100644
index 000000000..ab351e274
--- /dev/null
+++ b/Mailman/Bouncers/Netscape.py
@@ -0,0 +1,87 @@
+# Copyright (C) 1998,1999,2000 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""Netscape Messaging Server bounce formats.
+
+I've seen at least one NMS server version 3.6 (envy.gmp.usyd.edu.au) bounce
+messages of this format. Bounces come in DSN mime format, but don't include
+any -Recipient: headers. Gotta just parse the text :(
+"""
+
+import re
+import multifile
+import mimetools
+
+from Mailman.pythonlib.StringIO import StringIO
+
+pcre = re.compile(r'The following recipients did not receive your message:',
+ re.IGNORECASE)
+acre = re.compile(r'<(?P<addr>[^>]*)>')
+
+
+
+
+def process(msg):
+ if msg.gettype() <> 'multipart/report' or \
+ msg.getparam('report-type') <> 'delivery-status':
+ # then
+ return None
+ boundary = msg.getparam('boundary')
+ msg.fp.seek(0)
+ mfile = multifile.MultiFile(msg.fp)
+ mfile.push(boundary)
+ plainmsg = None
+ # find the text/plain subpart which must occur before a
+ # message/delivery-status part
+ while 1:
+ try:
+ more = mfile.next()
+ except multifile.Error, e:
+ # the message *looked* like a DSN, but it really wasn't :(
+ return None
+ if not more:
+ # we didn't find it
+ return None
+ s = StringIO(mfile.read())
+ msg = mimetools.Message(s)
+ if msg.gettype() == 'message/delivery-status':
+ break
+ elif msg.gettype() <> 'text/plain':
+ # we're looking at something else entirely
+ return None
+ plainmsg = msg
+ # Did we find a text/plain part?
+ if not plainmsg:
+ return None
+ # Total guesswork, based on captured examples...
+ addrs = []
+ while 1:
+ line = plainmsg.fp.readline()
+ if not line:
+ break
+ mo = pcre.search(line)
+ if mo:
+ # There seems to be an intervening blank line
+ line = plainmsg.fp.readline()
+ if not line:
+ break
+ line = plainmsg.fp.readline()
+ if not line:
+ break
+ mo = acre.search(line)
+ if mo:
+ addrs.append(mo.group('addr'))
+ return addrs or None
diff --git a/Mailman/Bouncers/Postfix.py b/Mailman/Bouncers/Postfix.py
index 6ffe967da..122ab30c7 100644
--- a/Mailman/Bouncers/Postfix.py
+++ b/Mailman/Bouncers/Postfix.py
@@ -26,7 +26,7 @@ from Mailman.pythonlib.StringIO import StringIO
-def process(mlist, msg):
+def process(msg):
if msg.gettype() <> 'multipart/mixed':
return None
boundary = msg.getparam('boundary')
diff --git a/Mailman/Bouncers/Qmail.py b/Mailman/Bouncers/Qmail.py
index ba6ff83b4..77b439f41 100644
--- a/Mailman/Bouncers/Qmail.py
+++ b/Mailman/Bouncers/Qmail.py
@@ -34,7 +34,7 @@ acre = re.compile(r'<(?P<addr>[^>]*)>:')
-def process(mlist, msg):
+def process(msg):
msg.rewindbody()
# simple state machine
# 0 = nothing seen yet
diff --git a/Mailman/Bouncers/Smail.py b/Mailman/Bouncers/Smail.py
index 595c0c60b..56389a86c 100644
--- a/Mailman/Bouncers/Smail.py
+++ b/Mailman/Bouncers/Smail.py
@@ -27,7 +27,7 @@ endtag = '|------------------------- ' \
acre = re.compile(r'\s*address:\s*<(?P<addr>[^>]*)>')
-def process(mlist, msg):
+def process(msg):
msg.rewindbody()
# simple state machine
# 0 = nothing seen yet
diff --git a/Mailman/Bouncers/Yahoo.py b/Mailman/Bouncers/Yahoo.py
index 16e9dff5e..7db353f9f 100644
--- a/Mailman/Bouncers/Yahoo.py
+++ b/Mailman/Bouncers/Yahoo.py
@@ -25,7 +25,7 @@ ecre = re.compile(r'--- Original message follows')
-def process(mlist, msg):
+def process(msg):
# yahoo bounces seem to have a known subject value and something called an
# x-uidl header, the value of which seems unimportant
if string.lower(msg.get('from')) <> 'mailer-daemon@yahoo.com':