1
==========================
2
Command line list creation
3
==========================
5
A system administrator can create mailing lists by the command line.
15
You cannot create a mailing list in an unknown domain.
17
>>> from mailman.commands.cli_lists import Create
18
>>> command = Create()
21
... def error(self, message):
23
>>> command.parser = FakeParser()
25
>>> FakeArgs.listname = ['test@example.xx']
26
>>> command.process(FakeArgs)
27
Undefined domain: example.xx
29
The ``-d`` or ``--domain`` option is used to tell Mailman to auto-register the
30
domain. Both the mailing list and domain will be created.
32
>>> FakeArgs.domain = True
33
>>> command.process(FakeArgs)
34
Created mailing list: test@example.xx
36
Now both the domain and the mailing list exist in the database.
39
>>> from mailman.interfaces.listmanager import IListManager
40
>>> from zope.component import getUtility
41
>>> list_manager = getUtility(IListManager)
42
>>> list_manager.get('test@example.xx')
43
<mailing list "test@example.xx" at ...>
45
>>> from mailman.interfaces.domain import IDomainManager
46
>>> getUtility(IDomainManager).get('example.xx')
47
<Domain example.xx, base_url: http://example.xx,
48
contact_address: postmaster@example.xx>
50
You can also create mailing lists in existing domains without the
54
>>> FakeArgs.domain = False
55
>>> FakeArgs.listname = ['test1@example.com']
56
>>> command.process(FakeArgs)
57
Created mailing list: test1@example.com
59
>>> list_manager.get('test1@example.com')
60
<mailing list "test1@example.com" at ...>
62
The command can also operate quietly.
65
>>> FakeArgs.quiet = True
66
>>> FakeArgs.listname = ['test2@example.com']
67
>>> command.process(FakeArgs)
69
>>> mlist = list_manager.get('test2@example.com')
71
<mailing list "test2@example.com" at ...>
77
By default, no list owners are specified.
79
>>> dump_list(mlist.owners.addresses)
82
But you can specify an owner address on the command line when you create the
86
>>> FakeArgs.quiet = False
87
>>> FakeArgs.listname = ['test4@example.com']
88
>>> FakeArgs.owners = ['foo@example.org']
89
>>> command.process(FakeArgs)
90
Created mailing list: test4@example.com
92
>>> mlist = list_manager.get('test4@example.com')
93
>>> dump_list(repr(address) for address in mlist.owners.addresses)
94
<Address: foo@example.org [not verified] at ...>
96
You can even specify more than one address for the owners.
99
>>> FakeArgs.owners = ['foo@example.net',
100
... 'bar@example.net',
101
... 'baz@example.net']
102
>>> FakeArgs.listname = ['test5@example.com']
103
>>> command.process(FakeArgs)
104
Created mailing list: test5@example.com
106
>>> mlist = list_manager.get('test5@example.com')
107
>>> from operator import attrgetter
108
>>> dump_list(repr(address) for address in mlist.owners.addresses)
109
<Address: bar@example.net [not verified] at ...>
110
<Address: baz@example.net [not verified] at ...>
111
<Address: foo@example.net [not verified] at ...>
117
You can set the default language for the new mailing list when you create it.
118
The language must be known to Mailman.
121
>>> FakeArgs.listname = ['test3@example.com']
122
>>> FakeArgs.language = 'ee'
123
>>> command.process(FakeArgs)
124
Invalid language code: ee
126
>>> from mailman.interfaces.languages import ILanguageManager
127
>>> getUtility(ILanguageManager).add('ee', 'iso-8859-1', 'Freedonian')
128
<Language [ee] Freedonian>
130
>>> FakeArgs.quiet = False
131
>>> FakeArgs.listname = ['test3@example.com']
132
>>> FakeArgs.language = 'fr'
133
>>> command.process(FakeArgs)
134
Created mailing list: test3@example.com
136
>>> mlist = list_manager.get('test3@example.com')
137
>>> print mlist.preferred_language
138
<Language [fr] French>
139
>>> FakeArgs.language = None
145
When told to, Mailman will notify the list owners of their new mailing list.
147
>>> FakeArgs.listname = ['test6@example.com']
148
>>> FakeArgs.notify = True
149
>>> command.process(FakeArgs)
150
Created mailing list: test6@example.com
152
The notification message is in the virgin queue.
155
>>> from mailman.testing.helpers import get_queue_messages
156
>>> messages = get_queue_messages('virgin')
160
>>> for message in messages:
161
... print message.msg.as_string()
164
Subject: Your new mailing list: test6@example.com
165
From: noreply@example.com
166
To: foo@example.net, bar@example.net, baz@example.net
169
The mailing list 'test6@example.com' has just been created for you.
170
The following is some basic information about your mailing list.
172
You can configure your mailing list at the following web page:
174
http://lists.example.com/admin/test6@example.com
176
The web page for users of your mailing list is:
178
http://lists.example.com/listinfo/test6@example.com
180
There is also an email-based interface for users (not administrators)
181
of your list; you can get info about using it by sending a message
182
with just the word 'help' as subject or in the body, to:
184
test6-request@example.com
186
Please address all questions to noreply@example.com.