"Fossies" - the Fresh Open Source Software Archive

Member "mailman-3.3.7/src/mailman/commands/docs/aliases.rst" (10 Nov 2022, 2852 Bytes) of package /linux/misc/mailman-3.3.7.tar.bz2:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

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.

>>> from mailman.testing.documentation import cli >>> command = cli('mailman.commands.cli_aliases.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.

>>> from mailman.config import config >>> 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. :

>>> from mailman.app.lifecycle import create_list
>>> mlist = create_list('ant@example.com')

>>> import os, shutil, tempfile
>>> output_directory = tempfile.mkdtemp()
>>> ignore = cleanups.callback(shutil.rmtree, output_directory)
>>> command('mailman aliases --directory ' + output_directory)

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 ... ... ant@example.com lmtp:[lmtp.example.com]:24 ant-bounces@example.com lmtp:[lmtp.example.com]:24 ant-confirm@example.com lmtp:[lmtp.example.com]:24 ant-join@example.com lmtp:[lmtp.example.com]:24 ant-leave@example.com lmtp:[lmtp.example.com]:24 ant-owner@example.com lmtp:[lmtp.example.com]:24 ant-request@example.com lmtp:[lmtp.example.com]:24 ant-subscribe@example.com lmtp:[lmtp.example.com]:24 ant-unsubscribe@example.com lmtp:[lmtp.example.com]:24 <BLANKLINE>

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