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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
==================
The 'join' command
==================
The mail command 'join' subscribes an email address to the mailing list.
'subscribe' is an alias for 'join'.
>>> command = config.commands['join']
>>> print command.name
join
>>> print command.description
Join this mailing list. You will be asked to confirm your subscription
request and you may be issued a provisional password.
<BLANKLINE>
By using the 'digest' option, you can specify whether you want digest
delivery or not. If not specified, the mailing list's default will be
used. You can also subscribe an alternative address by using the
'address' option. For example:
<BLANKLINE>
join address=myotheraddress@example.com
<BLANKLINE>
>>> print command.argument_description
[digest=<yes|no>] [address=<address>]
No address to join
==================
>>> from mailman.email.message import Message
>>> from mailman.queue.command import Results
>>> mlist = create_list('alpha@example.com')
When no address argument is given, the message's From address will be used.
If that's missing though, then an error is returned.
>>> results = Results()
>>> print command.process(mlist, Message(), {}, (), results)
ContinueProcessing.no
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
join: No valid address found to subscribe
<BLANKLINE>
The 'subscribe' command is an alias.
>>> subscribe = config.commands['subscribe']
>>> print subscribe.name
subscribe
>>> results = Results()
>>> print subscribe.process(mlist, Message(), {}, (), results)
ContinueProcessing.no
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
subscribe: No valid address found to subscribe
<BLANKLINE>
Joining the sender
==================
When the message has a From field, that address will be subscribed.
>>> msg = message_from_string("""\
... From: Anne Person <anne@example.com>
...
... """)
>>> results = Results()
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.yes
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
Confirmation email sent to Anne Person <anne@example.com>
<BLANKLINE>
Anne is not yet a member because she must confirm her subscription request
first.
>>> from mailman.interfaces.usermanager import IUserManager
>>> from zope.component import getUtility
>>> print getUtility(IUserManager).get_user('anne@example.com')
None
Mailman has sent her the confirmation message.
>>> virginq = config.switchboards['virgin']
>>> qmsg, qdata = virginq.dequeue(virginq.files[0])
>>> print qmsg.as_string()
MIME-Version: 1.0
...
Subject: confirm ...
From: confirm-...@example.com
To: anne@example.com
...
<BLANKLINE>
Email Address Registration Confirmation
<BLANKLINE>
Hello, this is the GNU Mailman server at example.com.
<BLANKLINE>
We have received a registration request for the email address
<BLANKLINE>
anne@example.com
<BLANKLINE>
Before you can start using GNU Mailman at this site, you must first
confirm that this is your email address. You can do this by replying to
this message, keeping the Subject header intact. Or you can visit this
web page
<BLANKLINE>
http://lists.example.com/confirm/...
<BLANKLINE>
If you do not wish to register this email address simply disregard this
message. If you think you are being maliciously subscribed to the list, or
have any other questions, you may contact
<BLANKLINE>
postmaster@example.com
<BLANKLINE>
Once Anne confirms her registration, she will be made a member of the mailing
list.
>>> token = str(qmsg['subject']).split()[1].strip()
>>> from mailman.interfaces.domain import IDomainManager
>>> from mailman.interfaces.registrar import IRegistrar
>>> registrar = IRegistrar(IDomainManager(config)['example.com'])
>>> registrar.confirm(token)
True
>>> user = getUtility(IUserManager).get_user('anne@example.com')
>>> print user.real_name
Anne Person
>>> list(user.addresses)
[<Address: Anne Person <anne@example.com> [verified] at ...>]
Anne is also now a member of the mailing list.
>>> mlist.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com>
on alpha@example.com as MemberRole.member>
Joining a second list
=====================
>>> mlist_2 = create_list('baker@example.com')
>>> msg = message_from_string("""\
... From: Anne Person <anne@example.com>
...
... """)
>>> print command.process(mlist_2, msg, {}, (), Results())
ContinueProcessing.yes
Anne of course, is still registered.
>>> print getUtility(IUserManager).get_user('anne@example.com')
<User "Anne Person" at ...>
But she is not a member of the mailing list.
>>> print mlist_2.members.get_member('anne@example.com')
None
One Anne confirms this subscription, she becomes a member of the mailing list.
>>> qmsg, qdata = virginq.dequeue(virginq.files[0])
>>> token = str(qmsg['subject']).split()[1].strip()
>>> registrar.confirm(token)
True
>>> print mlist_2.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com>
on baker@example.com as MemberRole.member>
Leaving a mailing list
======================
The mail command 'leave' unsubscribes an email address from the mailing list.
'unsubscribe' is an alias for 'leave'.
>>> command = config.commands['leave']
>>> print command.name
leave
>>> print command.description
Leave this mailing list. You will be asked to confirm your request.
Anne is a member of the baker@example.com mailing list, when she decides to
leave it. She sends a message to the -leave address for the list and is sent
a confirmation message for her request.
>>> results = Results()
>>> print command.process(mlist_2, msg, {}, (), results)
ContinueProcessing.yes
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
Anne Person <anne@example.com> left baker@example.com
<BLANKLINE>
Anne is no longer a member of the mailing list.
>>> print mlist_2.members.get_member('anne@example.com')
None
Anne does not need to leave a mailing list with the same email address she's
subscribe with. Any of her registered, linked, and validated email addresses
will do.
>>> anne = getUtility(IUserManager).get_user('anne@example.com')
>>> address = anne.register('anne.person@example.org')
>>> results = Results()
>>> print mlist.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com>
on alpha@example.com as MemberRole.member>
>>> msg = message_from_string("""\
... To: alpha-leave@example.com
... From: anne.person@example.org
...
... """)
Since Anne's alternative address has not yet been verified, it can't be used
to unsubscribe Anne from the alpha mailing list.
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.no
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
Invalid or unverified address: anne.person@example.org
<BLANKLINE>
>>> print mlist.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com>
on alpha@example.com as MemberRole.member>
Once Anne has verified her alternative address though, it can be used to
unsubscribe her from the list.
>>> from datetime import datetime
>>> address.verified_on = datetime.now()
>>> results = Results()
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.yes
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
Anne Person <anne.person@example.org> left alpha@example.com
<BLANKLINE>
>>> print mlist.members.get_member('anne@example.com')
None
|