How to set up Mailman on Debian Jessie using Apache, Postfix and SpamAssassin in a virtualhost

In this post, I describe how to install and configure mailman for a virtual host on a Debian Jessie server using Apache, Postfix and SpamAssassin. Instructions on how to do this are in various places on the internet, but I didn’t find anywhere that collected all the different pieces together. These instructions should also work for Ubuntu.


Before starting, you’ll need to install Apache, Postfix and SpamAssassin. As this post is focused on Mailman I won’t talk about how to set up Apache, Postfix or SpamAssassin, as there are already plenty of good guides out there explaining how to configure them. I’ll only mention the changes required to their configuration for them to work with Mailman. Throughout this guide, I'll assume that you’re setting up Mailman on the domain

Install Mailman

Once Apache, Postfix and SpamAssassin are all set up and working, install Mailman with apt-get install mailman.

Configure Apache

Next, edit the Apache config for your site. In the <VirtualHost> section belonging to, add the following lines:

# We can find mailman here:
ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/
# And the public archives:
Alias /pipermail/ /var/lib/mailman/archives/public/
# Logos:
Alias /images/mailman/ /usr/share/images/mailman/
<Directory /usr/lib/cgi-bin/mailman/>
	AllowOverride None
	Options ExecCGI
	AddHandler cgi-script .cgi
	Require all granted
<Directory /var/lib/mailman/archives/public/>
	Options FollowSymlinks
	AllowOverride None
	Require all granted
<Directory /usr/share/images/mailman/>
	AllowOverride None
	Require all granted

Check that the new Apache config is valid using apache2ctl configtest. Assuming there are no errors, you can then tell Apache to pick up the new config with systemctl reload apache2.

Configure Mailman

Now create the default mailman mailing list. This is required before you can set up your own lists. The command is newlist mailman. Replace both instances of with your domain name.

Next, edit the Mailman config to tell it to use Postfix and SpamAssassin. Open /etc/mailman/ and add the following lines:

SPAMD_HOST    = 'localhost'

You can adjust the DISCARD_SCORE, HOLD_SCORE and MEMBER_BONUS as you prefer. Once that’s done, run service mailman restart. Then generate the mail aliases files with the command /usr/lib/mailman/bin/genaliases. This will automatically be kept up to date by Mailman when you add further mailing lists, but you need to manually generate it the first time.

DKIM considerations

You will probably want to add REMOVE_DKIM_HEADERS = Yes to /etc/mailman/ If you don’t, mail from domains that sign their messages using DKIM (this includes pretty much all major providers, including Gmail) are likely not to reach recipients’ inboxes due to spam filtering. The changes that Mailman makes to the message body before sending it on tend to invalidate the DKIM signature, but by default Mailman leaves DKIM headers intact even though they are no longer valid.

Configure Postfix

Edit /etc/postfix/ and put in the lines below. Most if not all of these lines should already be there. The key points are:

  1. alias_database should NOT include the Mailman aliases file.
  2. alias_maps must include the Mailman aliases file.
  3. virtual_alias_domains must include the domain(s) for your email lists, as well as any other active virtual domains (the sample config below includes as an active virtual mail domain that isn’t used by Mailman).
  4. virtual_alias_maps must include the Mailman virtual alias file.
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual, hash:/var/lib/mailman/data/virtual-mailman


Now you’re ready to test. Create a test mailing list with newlist test. Open in your browser, and you should see the mailing list’s information page. Subscribe to the list and try sending a test message to If it didn’t work, check your logs: /var/log/mail.log for Postfix, and /var/log/mailman/error for Mailman. Try sending a regular message to make sure that it gets through, and a message including the GTUBE to make sure that spam is being filtered correctly.

Add Mailman cron jobs

Finally, set up cron jobs so that Mailman automatically does regular housekeeping by running the command crontab -u list /var/lib/mailman/cron/

Add new comment