Mailman 3 installation

I recently installed Mailman 3 on a Gentoo Linux server. Additional to the normal setup, I separated the mail backend from the admin interface in two different container (using Linux-Vserver). I will now describe the process and the necessary configuration changes.

The process is inspired by the 5 Minute guide to Mailman web UI, but is extended with the required changes.


The backend, is the part, that manages the mailing lists and handles all email traffic. So I decided to install it on my mail server. To separate it from the system I first created a new user for Mailman 3.

root@mail # useradd -md /var/lib/mailman3/ mailman3

Now we need at first the current mailman code. Bazaar is the simplest way to get it, so we first need to install it, if its not available yet:

root@mail # emerge dev-vcs/bzr

Then we could get the code. The following actions all are executed within the just created user account:

root@mail # su - mailman3
mailman3@mail $ bzr branch lp:mailman
Branched 7155 revision(s).

Now we have the code and could build and test it.

mailman3@mail $ cd mailman
mailman3@mail $ python2
mailman3@mail $ bin/buildout
mailman3@mail $ bin/test

Notice the python2 binary, that you have to use, if your default system wide python interpreter is set to use python3. is generating scripts in the bin directory. These scrips using the same interpreter, that was used to run the script.

For customization of the configuration you could choose different options for the new configuration file.

  • -C config command line option
  • $MAILMAN_CONFIG_FILE environment variable
  • ./mailman.cfg
  • ~/.mailman.cfg
  • /etc/mailman.cfg
  • argv[0]/../../etc/mailman.cfg

I choose to put the config into ~/.mailman.cfg. Additional to that I created a symlink from ~/etc/mailman.cfg to that file. With that link it should be easier to find the configuration file.

The default configuration, supplied with the mailman source code, should work for most installation. But you will notice if you start Mailman 3, that the REST-API interface only listen on localhost. If you want to connect from another server, you will need to change this.

hostname: mail

You might think, that it would be a good idea to set the hostname to, to let it bind on any interface. This would work in first place. But some API calls return a URL to get more information and you will then get something starting with, which is obviously not a valid URL. Therefor the hostname option should be set to the hostname or IP address on that, the backend will be reachable from the admin interface.

You also may change the default username and the password you need to access the API interface. This is strongly recommend if the interface is public reachable from the Internet. Just add admin_user and admin_pass to the config file under the webservice section.

Additional you may want to change the database backend. The default config uses sqlite. If you want to use a PostgreSQL instead, you could use the example from the documentation in src/mailman/docs/DATABASE.rst.

After all customization you could start the backend with the script bin/mailman. I recommend to change to the home directory of the mailman3 user, before executing this script. In the working directory of the script a new directory /var with runtime data is created:

mailman3@mail $ cd ~
mailman3@mail $ mailman/bin/mailman start
Starting Mailman's master runner

Additional to the configuration of the mailman server, you need to integrate mailman into you mail server. However, this setup heavily depends the configuration of you mail server. Please refer to the official documentation in src/mailman/docs/MTA.rst for possibly ways.

Django Webinterface

The second part of the installation is a bit more complicated. The webinterface needs multiple components that should be installed in the python path. To not pollute the system with a system wide install as root, i choose again to install it with a separate user. For easy installation I use virtualenv with virtualenvwrapper as frontend.

To use it, I first installed the required packages. Because I installed the webinterface on another server, I have to install bazaar and create the mailman3 user, again.

root@web # emerge dev-vcs/bzr dev-python/virtualenvwrapper
root@web # useradd -md /var/www/ mailman3
root@web # su - mailman3

To use the virtualenvwrapper you need to source a script on each login. To automate it, you could simply add a line to you .bashrc:

mailman3@web $ echo "source /usr/bin/" >> ~/.bashrc

Then we create virtualenv for use with Mailman 3. The functions from the wrapper makes it easy. You may want to use that virtualenv on each login, so you want to add the workon command to your bashrc, too.

mailman3@web $ mkvirtualenv -ppython2.7 mailman
Already using interpreter /usr/bin/python2.7
New python executable in mailman/bin/python2.7
Also creating executable in mailman/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /var/www/
virtualenvwrapper.user_scripts creating /var/www/
virtualenvwrapper.user_scripts creating /var/www/
virtualenvwrapper.user_scripts creating /var/www/
virtualenvwrapper.user_scripts creating /var/www/
mailman3@web $ echo "workon mailman" >> ~/.bashrc

With all preparations completed, you could now start to setup the Mailman 3 specific software. The following steps are equal to the steps from the 5 minute howto referenced before.

First we need to install mailman.client for the communication with the backend.

mailman3@web $ bzr branch lp:mailman.client
mailman3@web $ cd mailman.client
mailman3@web $ python develop
mailman3@web $ cd ..

Notice the missing of the sudo command in contrast to the referenced howto. By using virtualenv the installation could be done as user.

The next step in the howto is the installation of Django. I skipped this step, because it get installed later as dependency of the web interface.

So you could just install postorius and all its dependencies (note again the missing sudo):

mailman3@web $ bzr branch lp:postorius
mailman3@web $ cd postorius
mailman3@web $ python develop

After installation you need a Django config. You could use the dev_setup directory as basis. If you installed the backend on another server you have to change at least the REST_SERVER settings in the Also you should adjust the API_USER and API_PASS settings to match the admin_user and admin_pass settings from the backend.

Again you could change the database configuration. But refer to the official Django documentation for the details.

Now you could initialize the database for the web interface. This is done like in any other Django application. You change into the directory where the is located and execute the following commands:

mailman3@web $ python syncdb

Please note: If you are using a virtualenv, you should not call the directly. ./ would use /usr/bin/python as interpreter and would not respect the virtualenv.

The last step now is to start the Django server. There are different possibilities. The simplest way, would be to start the development server just using the

mailman3@web $ python runserver

I decided to host the Django application using the fastcgi mode of the and serve it with a nginx. Therefor you need some other commands.

mailman3@web $ pip install flup
mailman3@web $ mkdir ~/var
mailman3@web $ python runfcgi socket=~/var/mailman3.sock method=prefork pidfile=~/var/ umask=000

With that server running, the only thing left to do, is to configure the nginx to proxy the requests as fastcgi to that server. You could use maybe something like that:

 server {
     listen *:80;

     access_log /var/log/nginx/animux.de_mailman3.access_log main;
     error_log /var/log/nginx/animux.de_mailman3.error_log info;

     root /var/www/;

     location /static/ {
             alias /var/www/;
             expires 30d;

     location /media/ {
             alias /var/www/;
             expires 30d;

     location / {
             fastcgi_split_path_info ^()(.*)$;
             fastcgi_pass unix:/var/www/;
             fastcgi_read_timeout 5m;

             include /etc/nginx/fastcgi_params;

After a restart of the nginx the webinterface should be available and you should be able to login with the account, you just created using the syncdb command before.

Comments !