Mlmmj mailing-list setup: Difference between revisions

From Hackers & Designers
No edit summary
No edit summary
Line 3: Line 3:
}}
}}


<code>*-smart</code> outputs better typography (eg straight quotes to curly quotes, etc)
This is a reference guide to setup the [http://mlmmj.org/ mlmm] mailing list software on a Debian machine.


<span id="convert-.docx-to-.md-without-column-widthpagination"></span>
''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''.
== convert .docx to .md without column-width/pagination ==


<code>pandoc -s input.docx -t markdown-smart -o output.md --wrap=none</code>
<span id="prerequisites"></span>
== Prerequisites ==


<span id="convert-all-.docx-files-in-current-folder"></span>
* A basic email server using <code>postfix</code>; see ''Postfix Setup'' for more
== convert all .docx files in current folder ==
* MX and A records of your list domain name correctly setup in your DNS settings


<code>find . -name &quot;*.docx&quot; -exec pandoc -s {} -t markdown-smart -o {}.md --wrap=none \;</code>
<span id="installation"></span>
== Installation ==


<span id="convert-markdown-to-mediawiki-to-clipboard"></span>
<code>mlmmj</code> is a CLI program written in <code>C</code>: 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.
== convert markdown to mediawiki to clipboard ==


<code>pandoc -s file.txt -t mediawiki | pbcopy</code>
Check and upgrade Debian system:


<span id="convert-all-doc-files-in-current-folder-to-docx"></span>
<pre>sudo apt-get update &amp;&amp; apt-get upgrade</pre>
== convert all doc files in current folder to docx ==
Then install <code>mlmmj</code>:


<code>textutil -convert docx *.doc</code>
<pre>sudo apt-get install mlmmj</pre>
This creates a <code>spool</code> directory for it under <code>/var/spool/mlmmj</code>. Under <code>/var/spool</code> you usually find also the <code>mail</code> and <code>postfix</code> directory, in Debian systems.
 
As per <code>mlmmj</code> [http://mlmmj.org/docs/readme-postfix/ recommendation], let’s make a <code>mlmmj</code> system user:
 
<pre>sudo adduser mlmmj --system --home /var/spool/mlmmj --disabled-password --disabled-login</pre>
We set the following options:
 
* <code>--system</code>, we create it as a system user as it has no password and no login, because this user acts an automatic process
* <code>--home &lt;path&gt;</code>, we set the user’s home directory to mlmmj’s spool directory, instead of the usual <code>home/mlmmj</code>
* <code>--disabled-password</code>, no password
* <code>--disabled-login</code>, 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 <code>mlmmj</code>:
 
<pre>sudo chown -R mlmmj /var/spool/mlmmj/</pre>
And finally we make a new <code>systemd</code> entry:
 
<pre>sudo vi /etc/systemd/system/mlmmj.service</pre>
with the following config, taken from https://github.com/tchapi/mlmmj-service-wrapper/blob/master/mlmmj.service
 
<pre>[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</pre>
Let’s start the service:
 
<pre>sudo systemctl start mlmmj</pre>
Before testing out our new setup, we need to make some adjustments to <code>postfix</code>.
 
In <code>/etc/postfix/main.cf</code>, make sure to have configured a ''recipient delimiter'':
 
<pre>recipient_delimiter = +</pre>
And that our ''transport maps'' are the following:
 
<pre>virtual_alias_maps = hash:/etc/postfix/virtual
transport_maps = hash:/etc/postfix/transport
mlmmj_destination_recipient_limit = 1</pre>
In <code>/etc/postfix/virtual</code> we set the following line for each list we want to use:
 
<pre>test@lists.hackersanddesigners.nl    lists.hackersanddesigners.nl--test@localhost.mlmmj
news@lists.hackersanddesigners.nl    lists.hackersanddesigners.nl--news@localhost.mlmmj</pre>
where: - <code>test</code> or <code>news</code> is replaced with the name of the list - <code>lists.hackersanddesigners.nl</code> with the domain name we want to use (and setup earlier in our DNS). - <code>localhost.mlmmj</code> is a dummy domain used by <code>mlmmj</code> to connect this virtual alias to mlmmj transports
 
For example:
 
<pre>flower@lists.acidgreen.nl    lists.acidgreen.nl--flower@localhost.mlmmj</pre>
We do the same in <code>/etc/postfix/transport</code>, by adding the following line:
 
<pre>lists.hackersanddesigners.nl--test@localhost.mlmmj        mlmmj:test</pre>
and replacing:
 
* <code>lists.hackersanddesigners.nl</code> to the domain we want to use
* <code>test</code> to the list name
 
After, let’s compile these two files to a format that <code>postfix</code> likes more, and reload <code>postfix</code>:
 
<pre>sudo postmap virtual
sudo postmap transport
sudo postfix reload</pre>
Lastly, let’s add a config line to the end of <code>/etc/postfix/master.cf</code>
 
<pre># mlmmj mailing lists
mlmmj  unix  -      n      n      -      -      pipe
  flags=DORhu user=mlmmj argv=/usr/bin/mlmmj-receive -F -L /var/spool/mlmmj/$nexthop</pre>
this tells <code>postfix</code> to process incoming emails with a script command (<code>mlmmj-receive</code>) ran by the <code>mlmmj</code> user, and to use certain flags (other settings useful for <code>mlmmj</code>).
 
The script will send incoming emails to the <code>mlmmj</code> spool directory (<code>/var/spool/mlmmj</code>) 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, <code>mlmmj</code> will do that, etc.
 
We can now create a test list and see if all works!
 
<span id="commands"></span>
== Commands ==
 
<span id="make-a-list"></span>
=== Make a list ===
 
TODO: I think that because we setup a <code>systemd</code> process for <code>mlmmj</code>, then <code>mlmmj</code> asks us to run it not with <code>mlmmj-&lt;command&gt;</code> but with <code>/usr/bin/mlmmj-&lt;command&gt;</code>. Get a grip on why it’s like this…
 
<pre>sudo /usr/bin/mlmmj-make-ml -c mlmmj -L &lt;list-name&gt; -a</pre>
we create a new list using the <code>mlmmj-make-ml</code> command, and use:
 
* <code>-c</code>, to set the user who will ''own'' the new list directory under <code>/var/spool/mlmmj</code> (eg <code>/var/spool/mlmmj/test-list</code>)
* <code>-L</code>, to set the list name
 
get list of subscribers:
 
<span id="list-subscribers"></span>
=== List subscribers ===
 
<pre>sudo /usr/bin/mlmmj-list -L &lt;list-name&gt;</pre>
<span id="subscribe-and-unsubscribe-from-and-to-a-list"></span>
=== Subscribe and unsubscribe from and to a list ===
 
To subscribe, send an email to <code>&lt;list-name&gt;+subscribe@lists.hackersanddesigners.nl</code>. To unsubscribe, send an email to <code>&lt;list-name&gt;+unsubscribe@lists.hackersanddesigners.nl</code>.

Revision as of 13:26, 17 February 2023

MainNavigation No


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.

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.