StuRa Diskussion:Server/SRS14/2018

Aus Wiki StuRa HTW Dresden
Zur Navigation springen Zur Suche springen

Using the Postfix mail server

Mailman should work pretty much out of the box with a standard Postfix installation. It has been tested with various Postfix versions up to and including Postfix 2.1.5.

In order to support Mailman's optional VERP delivery, you will want to disable luser_relay (the default) and you will want to set recipient_delimiter for extended address semantics. You should comment out any luser_relay value in your main.cf and just go with the defaults. Also, add this to your main.cf file:

   recipient_delimiter = +

Using "+" as the delimiter works well with the default values for VERP_FORMAT and VERP_REGEXP in Defaults.py.

When attempting to deliver a message to a non-existent local address, Postfix may return a 450 error code. Since this is a transient error code, Mailman will continue to attempt to deliver the message for DELIVERY_RETRY_PERIOD - 5 days by default. You might want to set Postfix up so that it returns permanent error codes for non-existent local users by adding the following to your main.cf file:

   unknown_local_recipient_reject_code = 550

Finally, if you are using Postfix-style virtual domains, read the section on virtual domain support below.

Integrating Postfix and Mailman

You can integrate Postfix and Mailman such that when new lists are created, or lists are removed, Postfix's alias database will be automatically updated. The following are the steps you need to take to make this work.

In the description below, we assume that you've installed Mailman in the default location, i.e. /usr/local/mailman. If that's not the case, adjust the instructions according to your use of configure's --prefix and --with-var-prefix options.

Note: If you are using virtual domains and you want Mailman to honor your virtual domains, read the 6.1 section below first!

   Add this to the bottom of the $prefix/Mailman/mm_cfg.py file:
           DEFAULT_SERVER_LANGUAGE = 'de'
           MTA = 'Postfix'
   The MTA variable names a module in the Mailman/MTA directory which contains the mail server-specific functions to be executed when a list is created or removed.
   Look at the Defaults.py file for the variables POSTFIX_ALIAS_CMD and POSTFIX_MAP_CMD command. Make sure these point to your postalias and postmap programs respectively. Remember that if you need to make changes, do it in mm_cfg.py.
   Run the bin/genaliases script to initialize your aliases file.
           % cd /usr/local/mailman
           % bin/genaliases
         
   Make sure that the owner of the data/aliases and data/aliases.db file is mailman, that the group owner for those files is mailman, or whatever user and group you used in the configure command, and that both files are group writable:
           % su
           % chown mailman:mailman data/aliases*
           % chmod g+w data/aliases*
         
   Hack your Postfix's main.cf file to include the following path in your alias_maps variable:
             /usr/local/mailman/data/aliases
   Note that there should be no trailing .db. Do not include this in your alias_database variable. This is because you do not want Postfix's newaliases command to modify Mailman's aliases.db file, but you do want Postfix to consult aliases.db when looking for local addresses.
   You probably want to use a hash: style database for this entry. Here's an example:
           alias_maps = hash:/etc/postfix/aliases,
               hash:/usr/local/mailman/data/aliases
   When you configure Mailman, use the --with-mail-gid=mailman switch; this will be the default if you configured Mailman after adding the mailman owner. Because the owner of the aliases.db file is mailman, Postfix will execute Mailman's wrapper program as uid and gid mailman.

That's it! One caveat: when you add or remove a list, the aliases.db file will updated, but it will not automatically run postfix reload. This is because you need to be root to run this and suid-root scripts are not secure. The only effect of this is that it will take about a minute for Postfix to notice the change to the aliases.db file and update its tables.

Virtual domains

Note: This section describes how to integrate Mailman with Postfix for automatic generation of Postfix virtual_alias_maps for Mailman list addresses. Mailman's support of virtual domains is limited in that list names must be globally unique within a single Mailman instance, i.e., two lists may not have the same name even if they are in different domains.

Postfix 2.0 supports ``virtual alias domains, essentially what used to be called ``Postfix-style virtual domains in earlier Postfix versions. To make virtual alias domains work with Mailman, you need to do some setup in both Postfix and Mailman. Mailman will write all virtual alias mappings to a file called, by default, /usr/local/mailman/data/virtual-mailman. It will also use postmap to create the virtual-mailman.db file that Postfix will actually use.

First, you need to set up the Postfix virtual alias domains as described in the Postfix documentation (see Postfix's virtual(5) manpage). Note that it's your responsibility to include the virtual-alias.domain anything line as described manpage (in recent Postfix this is not required if the domain is included in virtual_alias_domains in main.cf); Mailman will not include this line in virtual-mailman. You are highly encouraged to make sure your virtual alias domains are working properly before integrating with Mailman.

Next, add a path to Postfix's virtual_alias_maps variable, pointing to the virtual-mailman file, e.g.:

   virtual_alias_maps = <your normal virtual alias files>,
       hash:/usr/local/mailman/data/virtual-mailman

assuming you've installed Mailman in the default location. If you're using an older version of Postfix which doesn't have the virtual_alias_maps variable, use the virtual_maps variable instead.

Next, in your mm_cfg.py file, you will want to set the variable POSTFIX_STYLE_VIRTUAL_DOMAINS to the list of virtual domains that Mailman should update. This may not be all of the virtual alias domains that your Postfix installation supports! The values in this list will be matched against the host_name attribute of mailing lists objects, and must be an exact match.

Here's an example. Say that Postfix is configured to handle the virtual domains dom1.ain, dom2.ain, and dom3.ain, and further that in your main.cf file you've got the following settings:

   myhostname = mail.dom1.ain
   mydomain = dom1.ain
   mydestination = $myhostname, localhost.$mydomain
   virtual_alias_maps =
       hash:/some/path/to/virtual-dom1,
       hash:/some/path/to/virtual-dom2,
       hash:/some/path/to/virtual-dom2

If in your virtual-dom1 file, you've got the following lines:

   dom1.ain  IGNORE
   @dom1.ain @mail.dom1.ain

this tells Postfix to deliver anything addressed to dom1.ain to the same mailbox at mail.dom1.com, its default destination.

In this case you would not include dom1.ain in POSTFIX_STYLE_VIRTUAL_DOMAINS because otherwise Mailman will write entries for mailing lists in the dom1.ain domain as

   mylist@dom1.ain         mylist
   mylist-request@dom1.ain mylist-request
   # and so on...

The more specific entries trump your more general entries, thus breaking the delivery of any dom1.ain mailing list.

However, you would include dom2.ain and dom3.ain in mm_cfg.py:

   POSTFIX_STYLE_VIRTUAL_DOMAINS = ['dom2.ain', 'dom3.ain']

Now, any list that Mailman creates in either of those two domains, will have the correct entries written to /usr/local/mailman/data/virtual-mailman.

As above with the data/aliases* files, you want to make sure that both data/virtual-mailman and data/virtual-mailman.db are user and group owned by mailman.

Create a site-wide mailing list

After you have completed the integration of Mailman and your mail server, you need to create a ``site-wide mailing list. This is the one that password reminders will appear to come from, and it is required for proper Mailman operation. Usually this should be a list called mailman, but if you need to change this, be sure to change the MAILMAN_SITE_LIST variable in mm_cfg.py. You can create the site list with this command, following the prompts:

   % bin/newlist mailman

Now configure your site list. There is a convenient template for a generic site list in the installation directory, under data/sitelist.cfg which can help you with this. You should review the configuration options in the template, but note that any options not named in the sitelist.cfg file won't be changed.

The template can be applied to your site list by running:

   % bin/config_list -i data/sitelist.cfg mailman

After applying the sitelist.cfg options, be sure you review the site list's configuration via the admin pages.

You should also subscribe yourself to the site list.

Start the Mailman qrunner

Mailman depends on a process called the ``qrunner to delivery all email messages it sees. You must start the qrunner by executing the following command from the $prefix directory:

   % bin/mailmanctl start
   % cp scripts/mailman /etc/init.d/mailman

Create the site password

There are two site-wide passwords that you can create from the command line, using the bin/mmsitepass script. The first is the ``site password which can be used anywhere a password is required in the system. The site password will get you into the administration page for any list, and it can be used to log in as any user. Think root for a Unix system, so pick this password wisely!

The second password is a site-wide ``list creator password. You can use this to delegate the ability to create new mailing lists without providing all the privileges of the site password. Of course, the owner of the site password can also create new mailing lists, but the list creator password is limited to just that special role.

To set the site password, use this command:

   % $prefix/bin/mmsitepass <your-site-password>

To set the list creator password, use this command: https://www.gnu.org/software/mailman/mailman-install/index.html

   % $prefix/bin/mmsitepass -c <list-creator-password>

It is okay not to set a list creator password, but you probably do want a site password.


Weblinks

https://www.gnu.org/software/mailman/mailman-install/index.html