summaryrefslogtreecommitdiff
path: root/src/mailman/rules/docs/administrivia.txt
blob: 082409622bf6292af9d90e7375f6930556c27c7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
=============
Administrivia
=============

The 'administrivia' rule matches when the message contains some common email
commands in the Subject header or first few lines of the payload.  This is
used to catch messages posted to the list which should have been sent to the
-request robot address.

    >>> mlist = create_list('_xtest@example.com')
    >>> mlist.administrivia = True
    >>> rule = config.rules['administrivia']
    >>> print rule.name
    administrivia

For example, if the Subject header contains the word 'unsubscribe', the rule
matches.

    >>> msg_1 = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: unsubscribe
    ...
    ... """)
    >>> rule.check(mlist, msg_1, {})
    True

Similarly, if the body of the message contains the word 'subscribe' in the
first few lines of text, the rule matches.

    >>> msg_2 = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: I wish to join your list
    ...
    ... subscribe
    ... """)
    >>> rule.check(mlist, msg_2, {})
    True

In both cases, administrivia checking can be disabled.

    >>> mlist.administrivia = False
    >>> rule.check(mlist, msg_1, {})
    False
    >>> rule.check(mlist, msg_2, {})
    False

To make the administrivia heuristics a little more robust, the rule actually
looks for a minimum and maximum number of arguments, so that it really does
seem like a mis-addressed email command.  In this case, the 'confirm' command
requires at least one argument.  We don't give that here so the rule will not
match.

    >>> mlist.administrivia = True
    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: confirm
    ...
    ... """)
    >>> rule.check(mlist, msg, {})
    False

But a real 'confirm' message will match.

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: confirm 12345
    ...
    ... """)
    >>> rule.check(mlist, msg, {})
    True

We don't show all the other possible email commands, but you get the idea.


Non-administrivia
=================

Of course, messages that don't contain administrivia, don't match the rule.

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: examine
    ...
    ... persuade
    ... """)
    >>> rule.check(mlist, msg, {})
    False

Also, only text/plain parts are checked for administrivia, so any email
commands in other content type subparts are ignored.

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: some administrivia
    ... Content-Type: text/x-special
    ...
    ... subscribe
    ... """)
    >>> rule.check(mlist, msg, {})
    False