blob: c0d4c10c93d28d1280ac9d34674616605338d82e (
plain) (
blame)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
==================
Generating aliases
==================
For some mail servers, Mailman must generate a data file that is 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 ``bin/mailman aliases`` command does this.
>>> class FakeArgs:
... output = None
... format = None
... simple = 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
... postfix_map_cmd: true
... """)
Let's create a mailing list and then display the transport map for it. We'll
send the output to stdout.
::
>>> FakeArgs.output = '-'
>>> mlist = create_list('test@example.com')
>>> command.process(FakeArgs)
# 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>
>>> config.pop('postfix')
Alternative output
==================
By using a command line switch, we can select a different output format. The
option must point to an alternative implementation of the
``IMailTransportAgentAliases`` interface.
Mailman comes with an alternative implementation that just prints the aliases,
with no adornment.
>>> FakeArgs.format = 'mailman.commands.cli_aliases.Dummy'
>>> command.process(FakeArgs)
test@example.com
test-bounces@example.com
test-confirm@example.com
test-join@example.com
test-leave@example.com
test-owner@example.com
test-request@example.com
test-subscribe@example.com
test-unsubscribe@example.com
<BLANKLINE>
A simpler way of getting the same output is with the ``--simple`` flag.
>>> FakeArgs.format = None
>>> FakeArgs.simple = True
>>> command.process(FakeArgs)
test@example.com
test-bounces@example.com
test-confirm@example.com
test-join@example.com
test-leave@example.com
test-owner@example.com
test-request@example.com
test-subscribe@example.com
test-unsubscribe@example.com
<BLANKLINE>
Mutually exclusive arguments
============================
You cannot use both ``--simple`` and ``--format``.
>>> FakeArgs.format = 'mailman.commands.cli_aliases.Dummy'
>>> FakeArgs.simple = True
>>> class Parser:
... def error(self, message):
... raise RuntimeError(message)
>>> command.parser = Parser()
>>> command.process(FakeArgs)
Traceback (most recent call last):
...
RuntimeError: Cannot use both -s and -f
|