mailman with postfix

Step 2 – getting a mailman listserver running with postfix.

This document describes how to set up a postfix installation on linux to work with the mailman listserver. The document is part of a set of four which collectively describe:

Step 1 – upstream SMTP authentication using TLS with postfix;
Step 2 – getting a mailman listserver running with postfix;
Step 3 – configuring lighttpd with SSL for mailman;
Step 4 – putting it all together and letting the world in.

Installation of mailman will be distribution dependent, but again is straightforward in debian (or Ubuntu or other debian derived distros) – just “apt-get install mailman“. There is a generic description of how to install with Debian on-line here.

Mailman needs the following additions to the postfix main.cf:

# mailman configuration options
#
owner_request_special = no
recipient_delimiter = +
unknown_local_recipient_reject_code = 550
# virtual maps database added – but note also alias_maps
virtual_maps = hash:/var/lib/mailman/data/aliases
# it is a good idea to run mailman lists on a subdomain (so that a single MX can point to the list server) so
relay_domains = lists.ourdomain.org
transport_maps = hash:/etc/postfix/transport
mailman_destination_recipient_limit = 1
#
# end mailman config

We now need to create the file “/etc/postfix/transport” which contains one line:

lists.ourdomain.org mailman:

save it and run “postmap transport” to create the db file.

Mailman as a transport type should already be integrated into postfix. This transport file allows postfix to identify traffic which should be handled by mailman rather than by postfix itself. (Hence the separate subdomain for mailman list traffic). We need to ensure that the postfix “master.cf” file correctly identifies mailman traffic to be handled by the external mailman scripts by checking that file
contains the following:

mailman unix – n n – – pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${mailbox}

See the postfix master documentation for details about the master file and process.

Don’t forget to reload postfix after any changes to master.cf or main.cf

We now need to modify the mailman config file “/etc/mailman/mm_cfg.py” to reflect the postfix installation. A copy of the relevant part of my (anonymised) local config is below. Note that my URL pattern is “https://%s/cgi-bin/mailman/” rather than the more conventional https:// because I chose to run my mailman installation with an SSL enabled webserver. The choice is yours.

#####################################################
# Put YOUR site-specific configuration below, in mm_cfg.py . #
# See Defaults.py for explanations of the values. #

#————————————————————-
# The name of the list Mailman uses to send password reminders
# and similar. Don’t change if you want mailman-owner to be
# a valid local part.
MAILMAN_SITE_LIST = ‘mailman’

#————————————————————-
# If you change these, you have to configure your http server
# accordingly (Alias and ScriptAlias directives in most httpds)
# DEFAULT_URL_PATTERN = ‘https://%s/cgi-bin/mailman/’

DEFAULT_URL_PATTERN = ‘https://%s/mailman/’
PRIVATE_ARCHIVE_URL = ‘/mailman/private’
IMAGE_LOGOS = ‘/images/mailman/’

#————————————————————-
# Default domain for email addresses of newly created MLs
DEFAULT_EMAIL_HOST = ‘lists.ourdomain.org’
#————————————————————-
# Default host for web interface of newly created MLs
DEFAULT_URL_HOST = ‘lists.ourdomain.org’
#————————————————————-
# Required when setting any of its arguments.
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)

#————————————————————-
# The default language for this server.
DEFAULT_SERVER_LANGUAGE = ‘en’

#————————————————————-
# Iirc this was used in pre 2.1, leave it for now
USE_ENVELOPE_SENDER = 0 # Still used?

#————————————————————-
# Unset send_reminders on newly created lists
DEFAULT_SEND_REMINDERS = 0

#————————————————————-
# Uncomment this if you configured your MTA such that it
# automatically recognizes newly created lists.
# (see /usr/share/doc/mailman/README.Exim4.Debian)
# MTA=None # Misnomer, suppresses alias output on newlist
DEB_LISTMASTER = ‘postmaster@ourdomain.org’

#————————————————————-
# Uncomment if you use Postfix virtual domains, but be sure to
# see /usr/share/doc/mailman/README.Debian first.
MTA=’Postfix’

#————————————————————-
# Uncomment if you want to filter mail with SpamAssassin. For
# more information please visit this website:
# https://www.jamesh.id.au/articles/mailman-spamassassin/
# GLOBAL_PIPELINE.insert(1, ‘SpamAssassin’)

# Note – if you’re looking for something that is imported from mm_cfg, but you
# didn’t find it above, it’s probably in /usr/lib/mailman/Mailman/Defaults.py.
#
# end mm_cfg.py

Having finished the configuration, we need to add the required mailman aliases for the mailman list itself to the mail system /etc/aliases file . So add the following:

## mailman mailing list
mailman: “|/var/lib/mailman/mail/mailman post mailman”
mailman-admin: “|/var/lib/mailman/mail/mailman admin mailman”
mailman-bounces: “|/var/lib/mailman/mail/mailman bounces mailman”
mailman-confirm: “|/var/lib/mailman/mail/mailman confirm mailman”
mailman-join: “|/var/lib/mailman/mail/mailman join mailman”
mailman-leave: “|/var/lib/mailman/mail/mailman leave mailman”
mailman-owner: “|/var/lib/mailman/mail/mailman owner mailman”
mailman-request: “|/var/lib/mailman/mail/mailman request mailman”
mailman-subscribe: “|/var/lib/mailman/mail/mailman subscribe mailman”
mailman-unsubscribe: “|/var/lib/mailman/mail/mailman unsubscribe mailman”
# end of mailman additions.

and run the command “newaliases” to generate the database.

To create the site wide mailman list to go with the aliases above we need to run the command “newlist mailman“, give the email address of the site administrator (ours) and a password. This account is effectively the “root” or administrator for mailman so bear that in mind when choosing a password. The site wide admin can create other lists and will be used to set up our new lists later. You should soon know whether the new mailman list has been created correctly because you will receive a “welcome” email from the list at the email address entered at this stage.

After running “newlist” we need to update the list aliases database so type:

/usr/lib/mailman/bin/genaliases which will update /var/lib/mailman/data/aliases.

and restart mailman to take our new settings

/etc/init.d/mailman force-reload

Before we can go any further, we need to get mailman working with our webserver. This is supposedly relatively easy if you use apache and most on-line resources I found assumed that apache would be the server of choice. However, apache is a little heavy for the slug and I had already installed lighttpd in preference, so we now need to go on to Step 3.

Permanent link to this article: https://baldric.net/mailman-with-postfix/