summaryrefslogtreecommitdiff
path: root/src/mailman/commands/docs/aliases.rst
blob: 75a9d3c11737e60f8a01666b0c4fa9c230c2d3d4 (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
==================
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
    <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

..
    Clean up.
    >>> config.pop('postfix')