Command line list creation

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

>>> command = cli('mailman.commands.cli_lists.create')

You can prevent creation of a mailing list in an unknown domain.

>>> command('mailman create --no-domain [email protected]')
Usage: create [OPTIONS] LISTNAME
Try 'create --help' for help.
<BLANKLINE>
Error: Undefined domain: example.xx

By default, Mailman will create the domain if it doesn’t exist.

>>> command('mailman create [email protected]')
Created mailing list: [email protected]

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('[email protected]')
<mailing list "[email protected]" at ...>

>>> from mailman.interfaces.domain import IDomainManager
>>> getUtility(IDomainManager).get('example.xx')
<Domain example.xx>

The command can also operate quietly.

>>> command('mailman create --quiet [email protected]')
>>> mlist = list_manager.get('[email protected]')
>>> mlist
<mailing list "[email protected]" 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.

>>> command('mailman create --owner [email protected] [email protected]')
Created mailing list: [email protected]e.com

>>> mlist = list_manager.get('[email protected]')
>>> dump_list(repr(address) for address in mlist.owners.addresses)
<Address: [email protected] [not verified] at ...>

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

>>> command('mailman create '
...         '--owner [email protected] '
...         '--owner [email protected] '
...         '--owner [email protected] '
...         '[email protected]')
Created mailing list: [email protected]

>>> mlist = list_manager.get('[email protected]')
>>> from operator import attrgetter
>>> dump_list(repr(address) for address in mlist.owners.addresses)
<Address: [email protected] [not verified] at ...>
<Address: [email protected] [not verified] at ...>
<Address: [email protected] [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.

>>> command('mailman create --language xx [email protected]')
Usage: create [OPTIONS] LISTNAME
Try 'create --help' for help.

Error: Invalid language code: xx

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

>>> command('mailman create --language xx [email protected]')
Created mailing list: [email protected]

>>> mlist = list_manager.get('[email protected]')
>>> print(mlist.preferred_language)
<Language [xx] Freedonian>

Notifications

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

>>> command('mailman create '
...         '--notify '
...         '--owner [email protected] '
...         '--owner [email protected] '
...         '--owner [email protected] '
...         '[email protected]')
Created mailing list: [email protected]

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: [email protected]
From: [email protected]
To: [email protected], [email protected], [email protected]
...

The mailing list '[email protected]' has just been created for you.
The following is some basic information about your mailing list.

There is 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:

    [email protected]

Please address all questions to [email protected]