Mlmmj mailing-list setup

From Hackers & Designers
Revision as of 14:33, 17 February 2023 by Fincato (talk | contribs) (update disclaimer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a reference guide to setup the mlmm mailing list software on a Debian machine.

This guide is still a draft version for now, put together by transcribing my log notes and using memory; the mailing list setup is 95% going to work, but there are other details I cannot swear upon (yet). I plan to reproduce the whole process on another VPS soon and double check the steps I reported here.

UPDATE: after writing this guide around 1 year ago, I still did not setup mlmmj on a new VPS, so please use this and the official installation notes from mlmmj (and as usual with Linux, pray the computer gods).

Prerequisites

  • A basic email server using postfix; see Postfix Setup for more
  • MX and A records of your list domain name correctly setup in your DNS settings

Installation

mlmmj is a CLI program written in C: fast, tiny and to the point. It can be “extended” by writing bash script or such when necessary (eg for batch subscription or unsubscription). List configuration is done by using text files, it’s all pretty unix-y. OK cool.

Check and upgrade Debian system:

sudo apt-get update && apt-get upgrade

Then install mlmmj:

sudo apt-get install mlmmj

This creates a spool directory for it under /var/spool/mlmmj. Under /var/spool you usually find also the mail and postfix directory, in Debian systems.

As per mlmmj recommendation, let’s make a mlmmj system user:

sudo adduser mlmmj --system --home /var/spool/mlmmj --disabled-password --disabled-login

We set the following options:

  • --system, we create it as a system user as it has no password and no login, because this user acts an automatic process
  • --home <path>, we set the user’s home directory to mlmmj’s spool directory, instead of the usual home/mlmmj
  • --disabled-password, no password
  • --disabled-login, no login

The above settings are also done to set the least amount of privilegies to the mlmmj user.

Let’s set the spool directory to be owned by mlmmj:

sudo chown -R mlmmj /var/spool/mlmmj/

And finally we make a new systemd entry:

sudo vi /etc/systemd/system/mlmmj.service

with the following config, taken from https://github.com/tchapi/mlmmj-service-wrapper/blob/master/mlmmj.service

[Unit]
Description=This script provides a simple wrapper for mlmmj run as a daemon
After=syslog.target network.target

[Service]
User=root
Type=forking
ExecStart=/usr/bin/mlmmj-maintd -d /var/spool/mlmmj

[Install]
WantedBy=multi-user.target

Let’s start the service:

sudo systemctl start mlmmj

Before testing out our new setup, we need to make some adjustments to postfix.

In /etc/postfix/main.cf, make sure to have configured a recipient delimiter:

recipient_delimiter = +

And that our transport maps are the following:

virtual_alias_maps = hash:/etc/postfix/virtual
transport_maps = hash:/etc/postfix/transport
mlmmj_destination_recipient_limit = 1

In /etc/postfix/virtual we set the following line for each list we want to use:

test@lists.hackersanddesigners.nl    lists.hackersanddesigners.nl--test@localhost.mlmmj
news@lists.hackersanddesigners.nl    lists.hackersanddesigners.nl--news@localhost.mlmmj

where: - test or news is replaced with the name of the list - lists.hackersanddesigners.nl with the domain name we want to use (and setup earlier in our DNS). - localhost.mlmmj is a dummy domain used by mlmmj to connect this virtual alias to mlmmj transports

For example:

flower@lists.acidgreen.nl    lists.acidgreen.nl--flower@localhost.mlmmj

We do the same in /etc/postfix/transport, by adding the following line:

lists.hackersanddesigners.nl--test@localhost.mlmmj        mlmmj:test

and replacing:

  • lists.hackersanddesigners.nl to the domain we want to use
  • test to the list name

After, let’s compile these two files to a format that postfix likes more, and reload postfix:

sudo postmap virtual
sudo postmap transport
sudo postfix reload

Lastly, let’s add a config line to the end of /etc/postfix/master.cf

# mlmmj mailing lists
mlmmj   unix  -       n       n       -       -       pipe
  flags=DORhu user=mlmmj argv=/usr/bin/mlmmj-receive -F -L /var/spool/mlmmj/$nexthop

this tells postfix to process incoming emails with a script command (mlmmj-receive) ran by the mlmmj user, and to use certain flags (other settings useful for mlmmj).

The script will send incoming emails to the mlmmj spool directory (/var/spool/mlmmj) in order to process them: if the email (sender) is trying to post to the list, and has access to it, the message is posted and being sent to every other address in that list; if the email asks to unsubscribe its sender, mlmmj will do that, etc.

We can now create a test list and see if all works!

Commands

Make a list

TODO: I think that because we setup a systemd process for mlmmj, then mlmmj asks us to run it not with mlmmj-<command> but with /usr/bin/mlmmj-<command>. Get a grip on why it’s like this…

sudo /usr/bin/mlmmj-make-ml -c mlmmj -L <list-name> -a

we create a new list using the mlmmj-make-ml command, and use:

  • -c, to set the user who will own the new list directory under /var/spool/mlmmj (eg /var/spool/mlmmj/test-list)
  • -L, to set the list name

get list of subscribers:

List subscribers

sudo /usr/bin/mlmmj-list -L <list-name>

Subscribe and unsubscribe from and to a list

To subscribe, send an email to <list-name>+subscribe@lists.hackersanddesigners.nl. To unsubscribe, send an email to <list-name>+unsubscribe@lists.hackersanddesigners.nl.