Tony's Site

Running Mailman 3 on Debian with Exim4

Introduction

I have decided to experiment with Mailman 3 to host mailing lists. I wish to use standard Debian packages where possible. In doing so I have experienced a number of problems so thought it might be worth while documenting them. This is still work in progress and only partially complete and may not be 100% fault free.

As an experiment I wish to use the domain lists.roxburgh.net to support my trials.

Initial Setup

The first step was to install the Debian packages - apt install mailman3-full. I was asked if I wanted to configure a database with dbconfig-common. As this is only a trial I said yes and then chose sqlite3. This happened twice. I then edited some of the configuration files.

/etc/mailman3/mailman.cfg

/etc/mailman3/mailman-web.cfg

Then restart both services - systemctl restart mailman3 mailman3-web.

Finally for this part, create a superuser using mailman-web createsuperuser

Apache Configuration

You need to configure apache for the Mailman website. Initially I used the folowing virtual host configuration. Also you need to set up an A record in your DNS for the lists domain.

<VirtualHost *:443>
  ServerName lists.roxburgh.net
  ServerAdmin web@roxburgh.net
  SSLEngine On
  SSLCertificateFile      /etc/letsencrypt/live/www.roxburgh.net/cert.pem
  SSLCertificateChainFile /etc/letsencrypt/live/www.roxburgh.net/chain.pem
  SSLCertificateKeyFile   /etc/letsencrypt/live/www.roxburgh.net/privkey.pem
  Alias /mailman3/favicon.ico /var/lib/mailman3/web/static/postorius/img/favicon.ico
  Alias /mailman3/static      /var/lib/mailman3/web/static
  <Directory "/var/lib/mailman3/web/static">
    Require all granted
  </Directory>
  <IfModule mod_proxy_uwsgi.c>
    ProxyPass /mailman3/favicon.ico !
    ProxyPass /mailman3/static !
    ProxyPass /mailman3 unix:/run/mailman3-web/uwsgi.sock|uwsgi://localhost/
  </IfModule>
</VirtualHost>

Configuring Exim

The standard configuration can be found here. I had to make one change to the MM3_HOME macro. Also you need to add +mm_domains to your local_domains list.

Main Configuration

domainlist mm_domains=lists.roxburgh.net
MM3_LMTP_PORT=8024
MM3_HOME=/var/lib/mailman3
MM3_UID=list
MM3_GID=list
MM3_LISTCHK=MM3_HOME/lists/${local_part}.${domain}

Router Configuration

mailman3_router:
  driver = accept
  domains = +mm_domains
  require_files = MM3_LISTCHK
  local_part_suffix_optional
  local_part_suffix = \
     -bounces   : -bounces+* : \
     -confirm   : -confirm+* : \
     -join      : -leave     : \
     -owner     : -request   : \
     -subscribe : -unsubscribe
  transport = mailman3_transport

Transport Configuration

mailman3_transport:
  driver = smtp
  protocol = lmtp
  allow_localhost
  hosts = localhost
  port = MM3_LMTP_PORT
  rcpt_include_affixes = true

You also need to set up an MX record in your DNS for your list domain.

Starting to Use

Once you have set up your server it is not clear what to do next, as I could find no documentation. There are two separate online interfaces to Mailman. /mailman3 takes you to the Mailman services Postorious and Hyperkitty. /mailman3/admin takes you to the Django admin console. After some experimentation I hit on the following basic configuration.

First use the Django console to set up details of your website domain. In the console select Sites under the Sites heading. Select Add site then enter the site URL and name.

In the Mailman service first create a new domain, referencing the site you just created as Web Host. Then create a list under that domain.

Then check that a directory exists for your new list under /var/lib/mailman3/lists/. You can then start to send messages to your new list.

Problems and Further Steps

The following paragraphs details problems I experienced as I started to test Mailman.

Email flood - Retry and timeout are misconfigured

My inbox started to get flooded with emails from Mailman, one every minute. These started with the message -

"Retry and timeout are misconfigured. Set retry larger than timeout, failure to do so will cause the tasks to be retriggered before completion".

Following a link in the email I found that I needed to add the following to /etc/mailman3/mailman-web.py. This is Debian bug 1051618

Q_CLUSTER = {'orm': 'default',
             'retry': 360,
             'save_limit': 100,
             'timeout': 300,
             'workers': 2}

Email flood - Auto-created primary key used when not defining a primary key type

Even with the previous problem fixed I continued to receive emails every minute. These contained lots of lines saying something like -

"django_mailman3.Profile: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the DjangoMailman3Config.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'"

This is Debian bug 1051617. This fault means Mailman3 is not viable as a live system, genuine problems would be lost in a sea of rubbish.`

Eventually I found a solution on the Internet, although I now can't find it again to give a link. The solution is to add the following to /etc/mailman3/mailman-web.py.

DEFAULT_AUTO_FIELD='django.db.models.AutoField'

Posts Not Appearing in Archive

Posting messages worked, in that they were forwarded to list members. However nothing appeared in the Hyperkitty archive screens. It took me a while to resolve this as it turned out there were three different problems.

example.com Shown as Site Name

On the archive screens the site name was shown as example.com. To fix this add the following line to /etc/mailman3/mailman-web.py.

SITE_ID = 0

Running Multiple Sites On One Server

I set up a second web site on the same server with its own lists, expecting each site would only show it's lists. In fact both sites showed all lists. This can be fixed by adding the following to /etc/mailman3/mailman-web.py.

FILTER_VHOST = True