From 7c81624ff362d13423b3092c55031634bc1fb81f Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Sat, 9 Sep 2000 03:32:23 +0000 Subject: New bounce detector for what I think is called "Microsoft SMTPSVC", certainly what MSN and a few other services use. --- Mailman/Bouncers/Microsoft.py | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Mailman/Bouncers/Microsoft.py diff --git a/Mailman/Bouncers/Microsoft.py b/Mailman/Bouncers/Microsoft.py new file mode 100644 index 000000000..76f226ad1 --- /dev/null +++ b/Mailman/Bouncers/Microsoft.py @@ -0,0 +1,61 @@ +# 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. + +"""Microsoft's `SMTPSVC' nears I kin tell.""" + +import string +import re +import multifile + +from Mailman.pythonlib.StringIO import StringIO + +scre = re.compile(r'transcript of session follows', re.IGNORECASE) + + + +def process(msg): + if msg.gettype() <> 'multipart/mixed': + return None + boundary = msg.getparam('boundary') + msg.fp.seek(0) + mfile = multifile.MultiFile(msg.fp) + mfile.push(boundary) + # find the first subpart, which has no mime type + try: + more = mfile.next() + except multifile.Error: + # the message *looked* like a DSN, but it really wasn't :( + return None + if not more: + # we didn't find it + return None + addrs = [] + # simple state machine + # 0 == nothng seen yet + # 1 == tag line seen + state = 0 + while 1: + line = mfile.readline() + if not line: + break + line = string.strip(line) + if state == 0: + if scre.search(line): + state = 1 + if state == 1: + if '@' in line: + addrs.append(line) + return addrs or [] -- cgit v1.2.3-70-g09d2