Generating aliasesΒΆ

For some mail servers, Mailman must generate data files that are used to hook Mailman up to the mail server. The details of this differ for each mail server. Generally these files are automatically kept up-to-date when mailing lists are created or removed, but you might occasionally need to manually regenerate the file. The mailman aliases command does this.

>>> class FakeArgs:
...     directory = None
>>> from mailman.commands.cli_aliases import Aliases
>>> command = Aliases()

For example, connecting Mailman to Postfix is generally done through the LMTP protocol. Mailman starts an LMTP server and Postfix delivers messages to Mailman as an LMTP client. By default this is done through Postfix transport maps.

Selecting Postfix as the source of incoming messages enables transport map generation.

>>> config.push('postfix', """
... [mta]
... incoming: mailman.mta.postfix.LMTP
... lmtp_host: lmtp.example.com
... lmtp_port: 24
... """)

Let’s create a mailing list and then display the transport map for it. We’ll write the appropriate files to a temporary directory.

>>> import os, shutil, tempfile
>>> output_directory = tempfile.mkdtemp()
>>> cleanups.append((shutil.rmtree, output_directory))

>>> FakeArgs.directory = output_directory
>>> mlist = create_list('test@example.com')
>>> command.process(FakeArgs)

For Postfix, there are two files in the output directory.

>>> files = sorted(os.listdir(output_directory))
>>> for file in files:
...     print(file)
postfix_domains
postfix_lmtp

The transport map file contains all the aliases for the mailing list.

>>> with open(os.path.join(output_directory, 'postfix_lmtp')) as fp:
...     print(fp.read())
# AUTOMATICALLY GENERATED BY MAILMAN ON ...
...
test@example.com               lmtp:[lmtp.example.com]:24
test-bounces@example.com       lmtp:[lmtp.example.com]:24
test-confirm@example.com       lmtp:[lmtp.example.com]:24
test-join@example.com          lmtp:[lmtp.example.com]:24
test-leave@example.com         lmtp:[lmtp.example.com]:24
test-owner@example.com         lmtp:[lmtp.example.com]:24
test-request@example.com       lmtp:[lmtp.example.com]:24
test-subscribe@example.com     lmtp:[lmtp.example.com]:24
test-unsubscribe@example.com   lmtp:[lmtp.example.com]:24

The relay domains file contains a list of all the domains.

>>> with open(os.path.join(output_directory, 'postfix_domains')) as fp:
...     print(fp.read())
# AUTOMATICALLY GENERATED BY MAILMAN ON ...
...
example.com example.com

Previous topic

Mailman runner control

Next topic

Display configuration values

This Page