4
The 'administrivia' rule matches when the message contains some common email
5
commands in the Subject header or first few lines of the payload. This is
6
used to catch messages posted to the list which should have been sent to the
7
-request robot address.
9
>>> from Mailman.configuration import config
10
>>> mlist = config.db.list_manager.create(u'_xtest@example.com')
11
>>> mlist.administrivia = True
12
>>> rule = config.rules['administrivia']
16
For example, if the Subject header contains the word 'unsubscribe', the rule
19
>>> msg_1 = message_from_string(u"""\
20
... From: aperson@example.com
21
... Subject: unsubscribe
24
>>> rule.check(mlist, msg_1, {})
27
Similarly, if the body of the message contains the word 'subscribe' in the
28
first few lines of text, the rule matches.
30
>>> msg_2 = message_from_string(u"""\
31
... From: aperson@example.com
32
... Subject: I wish to join your list
36
>>> rule.check(mlist, msg_2, {})
39
In both cases, administrivia checking can be disabled.
41
>>> mlist.administrivia = False
42
>>> rule.check(mlist, msg_1, {})
44
>>> rule.check(mlist, msg_2, {})
47
To make the administrivia heuristics a little more robust, the rule actually
48
looks for a minimum and maximum number of arguments, so that it really does
49
seem like a mis-addressed email command. In this case, the 'confirm' command
50
requires at least one argument. We don't give that here so the rule will not
53
>>> mlist.administrivia = True
54
>>> msg = message_from_string(u"""\
55
... From: aperson@example.com
59
>>> rule.check(mlist, msg, {})
62
But a real 'confirm' message will match.
64
>>> msg = message_from_string(u"""\
65
... From: aperson@example.com
66
... Subject: confirm 12345
69
>>> rule.check(mlist, msg, {})
72
We don't show all the other possible email commands, but you get the idea.
78
Of course, messages that don't contain administrivia, don't match the rule.
80
>>> msg = message_from_string(u"""\
81
... From: aperson@example.com
86
>>> rule.check(mlist, msg, {})
89
Also, only text/plain parts are checked for administrivia, so any email
90
commands in other content type subparts are ignored.
92
>>> msg = message_from_string(u"""\
93
... From: aperson@example.com
94
... Subject: some administrivia
95
... Content-Type: text/x-special
99
>>> rule.check(mlist, msg, {})