移至主內容

Setting up Mailman3 on Debian 11 (Bullseye)

Submitted by Franklin on

This article describes how to set up Mailman3 - The GNU Mailing List Management System on Debian Bullseye (Debian 11).  The documents of Mailman3 are pretty... abundant, but honestly pretty confusing too.  I won't nominate it to The Nobel Document Awards.

Anyway, here is my way to build up a reliable mailman3 system on Debian 11.  This article is a great help, but still there are something you need to keep in mind.


Why Debian Bullseye (11) not Bookworm(12)?

Debian Bookworm was released on June 2023.  When looking into some features like to disable user signup to avoid robots attacking, I was suggested to upgrade my django-mailman3 to 1.3.6+, which was in the repository of Bookworm.  HOWEVER, when I installed a whole new Bookworm system and installed new version of Mailman3, the django admin page was broken!  I couldn't do any admin tasks there.  I have no idea if it is a Debian packaging problem, or is an upstream issue, but I had no choice but to use Bullseye instead.  It sucks.


Before installing Mailman3 suite...

Mailman3 has a full package on Debian repository, so you can use a single apt command to install.  But before installing it with apt, there are plenty of work needed to be done, or you'll get into trouble sooner or later.

Key:  Make sure you install MySQL/MariaDB or Postgresql before installing Mailman3.

Though you can reconfigure Mailman3 to use MariaDB if you install it after Mailman3, but for the mailman3-web part it would still use sqlite, which gave me a hard time because I kept getting "database is locked" error messages when performing some operations like importing mails into lists.

So, before installing mailman3, install these first:

apt install postfix default-mysql-server default-mysql-client python3-pymysql python3-mysqldb dbconfig-mysql fail2ban sasl2-bin opendkim

I won't go into details about setting up postfix/saslauthd/opendkim.  You'll find /usr/share/doc/mailman3/README.debian pretty useful, but it will be there after installing mailman3 package.


Install Mailman3-full

apt install mailman3-full

Yeah, that's it.  It's well packaged and with MariaDB installed, it will automatically configured to use MariaDB, both mailman3 and mailman3-web.

One more thing to notice:

apt install libapache2-mod-wsgi-py3 libapache2-mod-uwsgi

Apache proxy_uwsgi module is necessary and needed to be enabled to make Mailman3 work.


Configurations

  1. Configure /etc/mailman3/mailman.cfg
[archiver.hyperkitty]
class: mailman_hyperkitty.Archiver
enable: yes
configuration: /etc/mailman3/mailman-hyperkitty.cfg

[language.master]
charset: utf-8

[language.en]
charset: utf-8
  1. Configure /etc/mailman3/mailman-web.py .  It is acutally the local settings (/usr/share/mailman3-web/settings_local.py is a symlink to this file).
    1. I disabled 'django_mailman3.lib.auth.fedora' in INSTALLED_APPS since I got some errors when some robots tried it and actually I didn't want users to register.
    2. The DATABASES section should have been set up since we installed MariaDB before Mailman3.  But I needed to add 
      'charset': 'utf8mb4'
      in OPTIONS to handle UTF8 characters properly.  Also in MariaDB we need to make sure it uses character set utf8mb4:
      ALTER DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 
    3. Set the TIMEZONE, HOSTNAME and EMAILNAME
    4. I just want users to subscribe mailing list through email but don't want them sign up on my Mailman3 instance, so I put this in mailman-web.py:
      ACCOUNT_ADAPTER = 'django_mailman3.views.user_adapter.DisableSignupAdapter'

      and to make it work, we need a user_adapter.py from Mailman3-1.3.9 in /usr/lib/python3/dist-packages/django_mailman3/views .  You can extracted it from the source code of Mailman3-1.3.9, or download it here.

It should be basically done here.  


Some other notes...

Most of the operation can be done by "mailman" command, but actually I performed it all with /usr/share/mailman3-web/manage.py .  To import a mbox file into a list, I used:

/usr/share/mailman3-web/manage.py hyperkitty_import -l <list> <mbox_file_path>

And build full_text index:

/usr/share/mailman3-web/manage.py update_index_one_list <list>

Here was what I figured out that if I didn't install MariaDB before Mailman3, it would still use sqlite and I got a lot ot database locked error when importing.

Hope this article helps!

 

[EDIT 2023/08/27]

Stephen J. Turnbull sent his comments on mm3-user mailing list, about "mailman" and "mailman-web" in my "Some Other Notes" section.  Honestly I was totally confused by all these, and as I have said, the MM3/Django/Hyperkitty/... documents didn't help much.  I saw the "mailman" command in some articles but got some problems when trying to run it (I forgot what problems).  Then I found that manage.py (in mailman3-web) which could perform all operations I wanted.  That's why I added this part.  Steve's comments made sense and it's a lot clearer now.  Thanks for the correction Stephen!

Stephen said:

In our current releases, the "mailman" command and the "mailman-web" command are separate.  mailman-web/manage.py and django-admin are basically aliases for mailman-web.  I think "mailman-web", not "mailman" is what you mean in your last note.  Note that "manage.py" doesn't know anything about functions of the "mailman" command, since it is derived from Django.  So you might want to check that and correct it.

標籤 (Tags)