Application level list life cycle

The low-level way to create and delete a mailing list is to use the IListManager interface. This interface simply adds or removes the appropriate database entries to record the list’s creation.

There is a higher level interface for creating and deleting mailing lists which performs additional tasks such as:

  • validating the list’s posting address (which also serves as the list’s fully qualified name);

  • ensuring that the list’s domain is registered;

  • applying a list style to the new list;

  • creating and assigning list owners;

  • notifying watchers of list creation;

  • creating ancillary artifacts (such as the list’s on-disk directory)

Creating a list with owners

You can also specify a list of owner email addresses. If these addresses are not yet known, they will be registered, and new users will be linked to them.

>>> owners = [
...     '',
...     '',
...     '',
...     '',
...     ]

>>> from import create_list
>>> ant = create_list('', owners)
>>> from mailman.testing.documentation import dump_list
>>> dump_list( for address in ant.owners.addresses)

None of the owner addresses are verified.

>>> any(address.verified_on is not None
...     for address in ant.owners.addresses)

However, all addresses are linked to users.

>>> from mailman.interfaces.usermanager import IUserManager
>>> from zope.component import getUtility
>>> user_manager = getUtility(IUserManager)
>>> for address in owners:
...     user = user_manager.get_user(address)
...     print(int(, list(user.addresses)[0])

If you create a mailing list with owner addresses that are already known to the system, they won’t be created again.

>>> bee = create_list('', owners)
>>> from operator import attrgetter
>>> for user in sorted(bee.owners.users, key=attrgetter('user_id')):
...     print(int(, list(user.addresses)[0])

Deleting a list

Removing a mailing list deletes the list, all its subscribers, and any related artifacts.

>>> from import remove_list
>>> remove_list(bee)

>>> from mailman.interfaces.listmanager import IListManager
>>> print(getUtility(IListManager).get(''))

We should now be able to completely recreate the mailing list.

>>> buzz = create_list('', owners)
>>> dump_list( for address in bee.owners.addresses)