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
|
=========
Pipelines
=========
This runner's purpose in life is to process messages that have been accepted
for posting, applying any modifications and also sending copies of the message
to the archives, digests, nntp, and outgoing queues. Pipelines are named and
consist of a sequence of handlers, each of which is applied in turn. Unlike
rules and chains, there is no way to stop a pipeline from processing the
message once it's started.
>>> mlist = create_list('xtest@example.com')
>>> print mlist.pipeline
built-in
>>> from mailman.core.pipelines import process
Processing a message
====================
Messages hit the pipeline after they've been accepted for posting.
>>> msg = message_from_string("""\
... From: aperson@example.com
... To: xtest@example.com
... Subject: My first post
... Message-ID: <first>
...
... First post!
... """)
>>> msgdata = {}
>>> process(mlist, msg, msgdata, mlist.pipeline)
The message has been modified with additional headers, footer decorations,
etc.
>>> print msg.as_string()
From: aperson@example.com
To: xtest@example.com
Message-ID: <first>
Subject: [Xtest] My first post
X-BeenThere: xtest@example.com
X-Mailman-Version: ...
Precedence: list
List-Id: <xtest.example.com>
X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Post: <mailto:xtest@example.com>
List-Subscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-join@example.com>
Archived-At:
http://lists.example.com/archives/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Unsubscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-leave@example.com>
List-Archive: <http://lists.example.com/archives/xtest@example.com>
List-Help: <mailto:xtest-request@example.com?subject=help>
<BLANKLINE>
First post!
<BLANKLINE>
And the message metadata has information about recipients and other stuff.
However there are currently no recipients for this message.
>>> dump_msgdata(msgdata)
original_sender : aperson@example.com
origsubj : My first post
recipients : set([])
stripped_subject: My first post
And the message is now sitting in various other processing queues.
>>> from mailman.testing.helpers import get_queue_messages
>>> messages = get_queue_messages('archive')
>>> len(messages)
1
>>> print messages[0].msg.as_string()
From: aperson@example.com
To: xtest@example.com
Message-ID: <first>
Subject: [Xtest] My first post
X-BeenThere: xtest@example.com
X-Mailman-Version: ...
Precedence: list
List-Id: <xtest.example.com>
X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Post: <mailto:xtest@example.com>
List-Subscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-join@example.com>
Archived-At:
http://lists.example.com/archives/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Unsubscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-leave@example.com>
List-Archive: <http://lists.example.com/archives/xtest@example.com>
List-Help: <mailto:xtest-request@example.com?subject=help>
<BLANKLINE>
First post!
<BLANKLINE>
>>> dump_msgdata(messages[0].msgdata)
_parsemsg : False
original_sender : aperson@example.com
origsubj : My first post
recipients : set([])
stripped_subject: My first post
version : 3
This mailing list is not linked to an NNTP newsgroup, so there's nothing in
the outgoing nntp queue.
>>> messages = get_queue_messages('news')
>>> len(messages)
0
This is the message that will actually get delivered to end recipients.
>>> messages = get_queue_messages('out')
>>> len(messages)
1
>>> print messages[0].msg.as_string()
From: aperson@example.com
To: xtest@example.com
Message-ID: <first>
Subject: [Xtest] My first post
X-BeenThere: xtest@example.com
X-Mailman-Version: ...
Precedence: list
List-Id: <xtest.example.com>
X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Post: <mailto:xtest@example.com>
List-Subscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-join@example.com>
Archived-At:
http://lists.example.com/archives/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Unsubscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-leave@example.com>
List-Archive: <http://lists.example.com/archives/xtest@example.com>
List-Help: <mailto:xtest-request@example.com?subject=help>
<BLANKLINE>
First post!
<BLANKLINE>
>>> dump_msgdata(messages[0].msgdata)
_parsemsg : False
listname : xtest@example.com
original_sender : aperson@example.com
origsubj : My first post
recipients : set([])
stripped_subject: My first post
version : 3
There's now one message in the digest mailbox, getting ready to be sent.
>>> from mailman.testing.helpers import digest_mbox
>>> digest = digest_mbox(mlist)
>>> sum(1 for mboxmsg in digest)
1
>>> print list(digest)[0].as_string()
From: aperson@example.com
To: xtest@example.com
Message-ID: <first>
Subject: [Xtest] My first post
X-BeenThere: xtest@example.com
X-Mailman-Version: ...
Precedence: list
List-Id: <xtest.example.com>
X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Post: <mailto:xtest@example.com>
List-Subscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-join@example.com>
Archived-At:
http://lists.example.com/archives/4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB
List-Unsubscribe:
<http://lists.example.com/listinfo/xtest@example.com>,
<mailto:xtest-leave@example.com>
List-Archive: <http://lists.example.com/archives/xtest@example.com>
List-Help: <mailto:xtest-request@example.com?subject=help>
<BLANKLINE>
First post!
<BLANKLINE>
<BLANKLINE>
Clean up the digests
====================
>>> digest.clear()
>>> digest.flush()
>>> sum(1 for msg in digest_mbox(mlist))
0
|