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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
=========================
RFC 2919 and 2369 headers
=========================
`RFC 2919`_ and `RFC 2369`_ define headers for mailing list actions. These
headers generally start with the `List-` prefix.
>>> mlist = create_list('test@example.com')
>>> mlist.preferred_language = 'en'
>>> mlist.archive = False
..
This is a helper function for the following section.
>>> def list_headers(msg, only=None):
... if isinstance(only, basestring):
... only = (only.lower(),)
... elif only is None:
... only = set(header.lower() for header in msg.keys()
... if header.lower().startswith('list-'))
... only.add('archived-at')
... else:
... only = set(header.lower() for header in only)
... print '---start---'
... for header in sorted(only):
... for value in sorted(msg.get_all(header, ())):
... print '%s: %s' % (header, value)
... print '---end---'
The `rfc-2369` handler adds the `List-` headers. `List-Id` is always added.
>>> from mailman.handlers.rfc_2369 import process
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg, 'list-id')
---start---
list-id: <test.example.com>
---end---
Fewer headers
=============
Some people don't like these headers because their mail readers aren't good
about hiding them. A list owner can turn these headers off.
>>> mlist.include_rfc2369_headers = False
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg)
---start---
---end---
Messages which Mailman generates itself, such as user or owner notifications,
have a reduced set of `List-` headers. Specifically, there is no `List-Post`,
`List-Archive` or `Archived-At` header.
..
>>> mlist.include_rfc2369_headers = True
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, dict(reduced_list_headers=True))
>>> list_headers(msg)
---start---
list-help: <mailto:test-request@example.com?subject=help>
list-id: <test.example.com>
list-subscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-join@example.com>
list-unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-leave@example.com>
---end---
List-Post header
================
Discussion lists, to which any subscriber can post, also have a `List-Post`
header which contains the `mailto:` URL used to send messages to the list.
>>> mlist.include_rfc2369_headers = True
>>> mlist.include_list_post_header = True
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg)
---start---
list-help: <mailto:test-request@example.com?subject=help>
list-id: <test.example.com>
list-post: <mailto:test@example.com>
list-subscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-join@example.com>
list-unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-leave@example.com>
---end---
Some mailing lists are announce, or one-way lists, not discussion lists.
Because the general membership cannot post to these mailing lists, the list
owner can set a flag which adds a special `List-Post` header value, according
to RFC 2369.
>>> mlist.include_list_post_header = False
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg)
---start---
list-help: <mailto:test-request@example.com?subject=help>
list-id: <test.example.com>
list-post: NO
list-subscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-join@example.com>
list-unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-leave@example.com>
---end---
List-Id header
==============
If the mailing list has a description, then it is included in the ``List-Id``
header.
>>> mlist.include_list_post_header = True
>>> mlist.description = 'My test mailing list'
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg)
---start---
list-help: <mailto:test-request@example.com?subject=help>
list-id: My test mailing list <test.example.com>
list-post: <mailto:test@example.com>
list-subscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-join@example.com>
list-unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-leave@example.com>
---end---
Any existing ``List-Id`` headers are removed from the original message.
>>> msg = message_from_string("""\
... From: aperson@example.com
... List-ID: <123.456.789>
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg, only='list-id')
---start---
list-id: My test mailing list <test.example.com>
---end---
Archive headers
===============
When the mailing list is configured to enable archiving, a `List-Archive`
header will be added.
>>> mlist.archive = True
`RFC 5064`_ defines the `Archived-At` header which contains the url to the
individual message in the archives. Archivers which don't support
pre-calculation of the archive url cannot add the `Archived-At` header.
However, other archivers can calculate the url, and do add this header.
>>> config.push('prototype', """
... [archiver.prototype]
... enable: yes
... [archiver.mail_archive]
... enable: no
... [archiver.mhonarc]
... enable: no
... [archiver.pipermail]
... enable: No
... """)
The *prototype* archiver can calculate this archive url given a `Message-ID`.
>>> msg = message_from_string("""\
... From: aperson@example.com
... Message-ID: <first>
... X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg, only=('list-archive', 'archived-at'))
---start---
archived-at: http://lists.example.com/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
list-archive: <http://lists.example.com>
---end---
If the mailing list isn't being archived, neither the `List-Archive` nor
`Archived-At` headers will be added.
>>> config.pop('prototype')
>>> mlist.archive = False
>>> msg = message_from_string("""\
... From: aperson@example.com
...
... """)
>>> process(mlist, msg, {})
>>> list_headers(msg)
---start---
list-help: <mailto:test-request@example.com?subject=help>
list-id: My test mailing list <test.example.com>
list-post: <mailto:test@example.com>
list-subscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-join@example.com>
list-unsubscribe: <http://lists.example.com/listinfo/test@example.com>,
<mailto:test-leave@example.com>
---end---
.. _`RFC 2919`: http://www.faqs.org/rfcs/rfc2919.html
.. _`RFC 2369`: http://www.faqs.org/rfcs/rfc2369.html
.. _`RFC 5064`: http://www.faqs.org/rfcs/rfc5064.html
|