1779
by Mark Sapiro
Bump copyright dates. |
1 |
# Copyright (C) 1998-2018 by the Free Software Foundation, Inc.
|
1
by
This commit was manufactured by cvs2svn to create branch |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or
|
|
4 |
# modify it under the terms of the GNU General Public License
|
|
5 |
# as published by the Free Software Foundation; either version 2
|
|
6 |
# of the License, or (at your option) any later version.
|
|
1007
by Mark Sapiro
Backported Bounce recognizer changes and tests from the 3.0 branch |
7 |
#
|
1
by
This commit was manufactured by cvs2svn to create branch |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1007
by Mark Sapiro
Backported Bounce recognizer changes and tests from the 3.0 branch |
12 |
#
|
1
by
This commit was manufactured by cvs2svn to create branch |
13 |
# You should have received a copy of the GNU General Public License
|
1007
by Mark Sapiro
Backported Bounce recognizer changes and tests from the 3.0 branch |
14 |
# along with this program; if not, write to the Free Software
|
853
by msapiro
Added another observed prefix 'unknown user:' |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
16 |
# USA.
|
|
1
by
This commit was manufactured by cvs2svn to create branch |
17 |
|
18 |
"""Something which claims
|
|
19 |
X-Mailer: <SMTP32 vXXXXXX>
|
|
20 |
||
21 |
What the heck is this thing? Here's a recent host:
|
|
22 |
||
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)
|
|
28 |
||
29 |
"""
|
|
30 |
||
31 |
import re |
|
32 |
import email |
|
33 |
||
34 |
ecre = re.compile('original message follows', re.IGNORECASE) |
|
35 |
acre = re.compile(r''' |
|
36 |
( # several different prefixes
|
|
37 |
user\ mailbox[^:]*: # have been spotted in the
|
|
38 |
|delivery\ failed[^:]*: # wild...
|
|
853
by msapiro
Added another observed prefix 'unknown user:' |
39 |
|unknown\ user[^:]*:
|
866
by msapiro
Fixed 'undeliverable to' pattern. It can have multiple spaces 'undeliverable to'. |
40 |
|undeliverable\ +to
|
1007
by Mark Sapiro
Backported Bounce recognizer changes and tests from the 3.0 branch |
41 |
|delivery\ userid[^:]*:
|
1
by
This commit was manufactured by cvs2svn to create branch |
42 |
)
|
43 |
\s* # space separator
|
|
1007
by Mark Sapiro
Backported Bounce recognizer changes and tests from the 3.0 branch |
44 |
(?P<addr>[^\s]*) # and finally, the address
|
1
by
This commit was manufactured by cvs2svn to create branch |
45 |
''', re.IGNORECASE | re.VERBOSE) |
46 |
||
47 |
||
48 |
||
49 |
def process(msg): |
|
50 |
mailer = msg.get('x-mailer', '') |
|
51 |
if not mailer.startswith('<SMTP32 v'): |
|
52 |
return
|
|
53 |
addrs = {} |
|
54 |
for line in email.Iterators.body_line_iterator(msg): |
|
55 |
if ecre.search(line): |
|
56 |
break
|
|
57 |
mo = acre.search(line) |
|
58 |
if mo: |
|
59 |
addrs[mo.group('addr')] = 1 |
|
60 |
return addrs.keys() |