4 To avoid a posting loop, Mailman has a rule to check for the existence of an
5 X-BeenThere header with the value of the list's posting address.
7 >>> from Mailman.configuration import config
8 >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
9 >>> from Mailman.app.rules import find_rule
10 >>> rule = find_rule('loop')
14 The header could be missing, in which case the rule does not match.
16 >>> msg = message_from_string(u"""\
17 ... From: aperson@example.com
19 ... An important message.
21 >>> rule.check(mlist, msg, {})
24 The header could be present, but not match the list's posting address.
26 >>> msg['X-BeenThere'] = u'not-this-list@example.com'
27 >>> rule.check(mlist, msg, {})
30 If the header is present and does match the posting address, the rule
33 >>> del msg['x-beenthere']
34 >>> msg['X-BeenThere'] = mlist.posting_address
35 >>> rule.check(mlist, msg, {})
38 Even if there are multiple X-BeenThere headers, as long as one with the
39 posting address exists, the rule matches.
41 >>> msg = message_from_string(u"""\
42 ... From: aperson@example.com
43 ... X-BeenThere: not-this-list@example.com
44 ... X-BeenThere: _xtest@example.com
45 ... X-BeenThere: foo@example.com
47 ... An important message.
49 >>> rule.check(mlist, msg, {})