summaryrefslogtreecommitdiff
path: root/src/mailman/commands/docs/create.rst
blob: 1a5d2a3ab495974c23b3e74aedbd713713cbd1db (plain)
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
==========================
Command line list creation
==========================

A system administrator can create mailing lists by the command line.

    >>> class FakeArgs:
    ...     language = None
    ...     owners = []
    ...     quiet = False
    ...     domain = None
    ...     listname = None
    ...     notify = False

You cannot create a mailing list in an unknown domain.

    >>> from mailman.commands.cli_lists import Create
    >>> command = Create()

    >>> class FakeParser:
    ...     def error(self, message):
    ...         print(message)
    >>> command.parser = FakeParser()

    >>> FakeArgs.listname = ['test@example.xx']
    >>> command.process(FakeArgs)
    Undefined domain: example.xx

The ``-d`` or ``--domain`` option is used to tell Mailman to auto-register the
domain.  Both the mailing list and domain will be created.

    >>> FakeArgs.domain = True
    >>> command.process(FakeArgs)
    Created mailing list: test@example.xx

Now both the domain and the mailing list exist in the database.
::

    >>> from mailman.interfaces.listmanager import IListManager
    >>> from zope.component import getUtility
    >>> list_manager = getUtility(IListManager)
    >>> list_manager.get('test@example.xx')
    <mailing list "test@example.xx" at ...>

    >>> from mailman.interfaces.domain import IDomainManager
    >>> getUtility(IDomainManager).get('example.xx')
    <Domain example.xx, base_url: http://example.xx>

You can also create mailing lists in existing domains without the
auto-creation flag.
::

    >>> FakeArgs.domain = False
    >>> FakeArgs.listname = ['test1@example.com']
    >>> command.process(FakeArgs)
    Created mailing list: test1@example.com

    >>> list_manager.get('test1@example.com')
    <mailing list "test1@example.com" at ...>

The command can also operate quietly.
::

    >>> FakeArgs.quiet = True
    >>> FakeArgs.listname = ['test2@example.com']
    >>> command.process(FakeArgs)

    >>> mlist = list_manager.get('test2@example.com')
    >>> mlist
    <mailing list "test2@example.com" at ...>


Setting the owner
=================

By default, no list owners are specified.

    >>> dump_list(mlist.owners.addresses)
    *Empty*

But you can specify an owner address on the command line when you create the
mailing list.
::

    >>> FakeArgs.quiet = False
    >>> FakeArgs.listname = ['test4@example.com']
    >>> FakeArgs.owners = ['foo@example.org']
    >>> command.process(FakeArgs)
    Created mailing list: test4@example.com

    >>> mlist = list_manager.get('test4@example.com')
    >>> dump_list(repr(address) for address in mlist.owners.addresses)
    <Address: foo@example.org [not verified] at ...>

You can even specify more than one address for the owners.
::

    >>> FakeArgs.owners = ['foo@example.net',
    ...                    'bar@example.net',
    ...                    'baz@example.net']
    >>> FakeArgs.listname = ['test5@example.com']
    >>> command.process(FakeArgs)
    Created mailing list: test5@example.com

    >>> mlist = list_manager.get('test5@example.com')
    >>> from operator import attrgetter
    >>> dump_list(repr(address) for address in mlist.owners.addresses)
    <Address: bar@example.net [not verified] at ...>
    <Address: baz@example.net [not verified] at ...>
    <Address: foo@example.net [not verified] at ...>


Setting the language
====================

You can set the default language for the new mailing list when you create it.
The language must be known to Mailman.
::

    >>> FakeArgs.listname = ['test3@example.com']
    >>> FakeArgs.language = 'ee'
    >>> command.process(FakeArgs)
    Invalid language code: ee

    >>> from mailman.interfaces.languages import ILanguageManager
    >>> getUtility(ILanguageManager).add('ee', 'iso-8859-1', 'Freedonian')
    <Language [ee] Freedonian>

    >>> FakeArgs.quiet = False
    >>> FakeArgs.listname = ['test3@example.com']
    >>> FakeArgs.language = 'fr'
    >>> command.process(FakeArgs)
    Created mailing list: test3@example.com

    >>> mlist = list_manager.get('test3@example.com')
    >>> print(mlist.preferred_language)
    <Language [fr] French>
    >>> FakeArgs.language = None


Notifications
=============

When told to, Mailman will notify the list owners of their new mailing list.

    >>> FakeArgs.listname = ['test6@example.com']
    >>> FakeArgs.notify = True
    >>> command.process(FakeArgs)
    Created mailing list: test6@example.com

The notification message is in the virgin queue.
::

    >>> from mailman.testing.helpers import get_queue_messages
    >>> messages = get_queue_messages('virgin')
    >>> len(messages)
    1

    >>> for message in messages:
    ...     print(message.msg.as_string())
    MIME-Version: 1.0
    ...
    Subject: Your new mailing list: test6@example.com
    From: noreply@example.com
    To: foo@example.net, bar@example.net, baz@example.net
    ...
    <BLANKLINE>
    The mailing list 'test6@example.com' has just been created for you.
    The following is some basic information about your mailing list.
    <BLANKLINE>
    You can configure your mailing list at the following web page:
    <BLANKLINE>
        http://lists.example.com/admin/test6@example.com
    <BLANKLINE>
    The web page for users of your mailing list is:
    <BLANKLINE>
        http://lists.example.com/listinfo/test6@example.com
    <BLANKLINE>
    There is also an email-based interface for users (not administrators)
    of your list; you can get info about using it by sending a message
    with just the word 'help' as subject or in the body, to:
    <BLANKLINE>
        test6-request@example.com
    <BLANKLINE>
    Please address all questions to noreply@example.com.
    <BLANKLINE>