1
# Copyright (C) 1998-2011 by the Free Software Foundation, Inc.
3
# This file is part of GNU Mailman.
5
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free
7
# Software Foundation, either version 3 of the License, or (at your option)
10
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
# You should have received a copy of the GNU General Public License along with
16
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18
"""Something which claims
19
X-Mailer: <SMTP32 vXXXXXX>
21
What the heck is this thing? Here's a recent host:
23
% telnet 207.51.255.218 smtp
24
Trying 207.51.255.218...
25
Connected to 207.51.255.218.
26
Escape character is '^]'.
27
220 X1 NT-ESMTP Server 208.24.118.205 (IMail 6.00 45595-15)
31
from __future__ import absolute_import, unicode_literals
41
from email.iterators import body_line_iterator
42
from zope.interface import implements
44
from mailman.interfaces.bounce import IBounceDetector
47
ecre = re.compile('original message follows', re.IGNORECASE)
48
acre = re.compile(r'''
49
( # several different prefixes
50
user\ mailbox[^:]*: # have been spotted in the
51
|delivery\ failed[^:]*: # wild...
54
|delivery\ userid[^:]*:
57
(?P<addr>[^\s]*) # and finally, the address
58
''', re.IGNORECASE | re.VERBOSE)
63
"""Something which claims
65
X-Mailer: <SMTP32 vXXXXXX>
68
implements(IBounceDetector)
70
def process(self, msg):
71
mailer = msg.get('x-mailer', '')
72
if not mailer.startswith('<SMTP32 v'):
75
for line in body_line_iterator(msg):
78
mo = acre.search(line)
80
addresses.add(mo.group('addr'))