Extended test_documentation.py to be able to find doctests in subdirectories
[mailman.git] / Mailman / rules / docs / suspicious.txt
blob8646e1b81c63a8383e2566805239aef6c6c05be8
1 Suspicious headers
2 ==================
4 Suspicious headers are a way for Mailman to hold messages that match a
5 particular regular expression.  This mostly historical feature is fairly
6 confusing to users, and the list attribute that controls this is misnamed.
8     >>> from Mailman.configuration import config
9     >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
10     >>> from Mailman.app.rules import find_rule
11     >>> rule = find_rule('suspicious-header')
12     >>> rule.name
13     'suspicious-header'
15 Set the so-called suspicious header configuration variable.
17     >>> mlist.bounce_matching_headers = u'From: .*person@(blah.)?example.com'
18     >>> msg = message_from_string(u"""\
19     ... From: aperson@example.com
20     ... To: _xtest@example.com
21     ... Subject: An implicit message
22     ... 
23     ... """)
24     >>> rule.check(mlist, msg, {})
25     True
27 But if the header doesn't match the regular expression, the rule won't match.
28 This one comes from a .org address.
30     >>> msg = message_from_string(u"""\
31     ... From: aperson@example.org
32     ... To: _xtest@example.com
33     ... Subject: An implicit message
34     ... 
35     ... """)
36     >>> rule.check(mlist, msg, {})
37     False