Mailman mailing list on OpenBSD 6.7
Tags: mailman, mailinglist, opensmtpd, openbsd
Published: 2019-10-06 13:05:43

---
title: Mailman mailing list on OpenBSD 6.7
published: true
description: With mail servers, Just forwarding emails to multiple addresses is easy. Also, we can build an advanced mailing list system. This post is about how to build a GNU Mailman server on OpenBSD.
tags: mailman, mailinglist, opensmtpd, openbsd
series: OpenBSD mailing lists
canonical_url: https://obsd.solutions/en/blog/2019/10/06/mailman-mailing-list-on-openbsd-67/index.html
---

## Summary

With mail servers, Just forwarding emails to multiple addresses is easy.
Also, we can build an advanced mailing list system.
This post is about how to build a [GNU Mailman](https://www.list.org/) server on [OpenBSD](https://www.openbsd.org).

#### Environment

- OS: OpenBSD 6.7
- MTA (Mail Transfer Agent): [OpenSMTPD](https://www.opensmtpd.org/)
- Mailing List Server: GNU Mailman 2.1

## Tutorial

The [package manager](https://www.openbsd.org/faq/faq15.html) is available and useful because it provides well-configured setting files as well as applications.
Just run:

```console
# pkg_add mailman
```
The result is:

```console
quirks-3.325 signed on 2020-06-04T16:43:21Z
mailman-2.1.32:python-2.7.18p0: ok
mailman-2.1.32:py-setuptools-41.6.0v0: ok
mailman-2.1.32:py-dnspython-1.16.0p2: ok
File /var/spool/mailman/data/sitelist.cfg could not be installed:
	No such file or directory
mailman-2.1.32: ok
The following new rcscripts were installed: /etc/rc.d/mailman
See rcctl(8) for details.
New and changed readme(s):
	/usr/local/share/doc/pkg-readmes/mailman
```

Well, it is useful to read `/usr/local/share/doc/pkg-readmes/mailman` above.

Then, edit the config file:

```console
# # (optional) make a backup beforehand:
# # cp -p /usr/local/lib/mailman/Mailman/mm_cfg.py /usr/local/lib/mailman/Mailman/mm_cfg.py.org

# nvim /usr/local/lib/mailman/Mailman/mm_cfg.py
```

to add the lines in the end of the file:

```diff
  # Put YOUR site-specific settings below this line.
+ MAILMAN_GROUP = '_mailman'
+ MAILMAN_USER = '_mailman'
```

It is because, without them, the errors below occur at starting the `mailman` daemon:

```
    gid = grp.getgrnam(mm_cfg.MAILMAN_GROUP)[2]
KeyError: 'getgrnam(): name not found: '
```

```
    uid = pwd.getpwnam(mm_cfg.MAILMAN_USER)[2]
KeyError: 'getpwnam(): name not found: '
```

Next, you need to create the first list in order to escape from the error at starting the `mailman` daemon:

```console
Site list is missing: mailman
```

The detail is [here](http://www.list.org/mailman-install/site-list.html) in the official documentation.

Run the Mailman command:

```console
# /usr/local/lib/mailman/bin/newlist mailman
```

which is followed by:

```console
Enter the email of the person running the list: <your@email.address>
Initial mailman password: 
```

```console
To finish creating your mailing list, you must edit your /etc/aliases (or
equivalent) file by adding the following lines, and possibly running the
`newaliases' program:

## mailman mailing list
mailman:              "|/usr/local/lib/mailman/mail/mailman post mailman"
mailman-admin:        "|/usr/local/lib/mailman/mail/mailman admin mailman"
mailman-bounces:      "|/usr/local/lib/mailman/mail/mailman bounces mailman"
mailman-confirm:      "|/usr/local/lib/mailman/mail/mailman confirm mailman"
mailman-join:         "|/usr/local/lib/mailman/mail/mailman join mailman"
mailman-leave:        "|/usr/local/lib/mailman/mail/mailman leave mailman"
mailman-owner:        "|/usr/local/lib/mailman/mail/mailman owner mailman"
mailman-request:      "|/usr/local/lib/mailman/mail/mailman request mailman"
mailman-subscribe:    "|/usr/local/lib/mailman/mail/mailman subscribe mailman"
mailman-unsubscribe:  "|/usr/local/lib/mailman/mail/mailman unsubscribe mailman"

Hit enter to notify mailman owner...
```

In order to follow the messages, edit it:

```console
# nvim /etc/mail/aliases
```

and run:

```console
# newaliases
/etc/mail/aliases: xx aliases
```

As it is written in `/usr/local/share/doc/pkg-readmes/mailman`, it is necessary to add a group to the MTA user:

```console
# usermod -G _mailmanq _smtpd
```

It is almost done.

Well, optionally, I had two additional modification.

\#1. I had to modify `/etc/mail/smtpd.conf` to let OpenSMTPD accept requests from `egress` to the mailing list domain.
I modified [`/etc/mail/smtpd.conf`](https://man.openbsd.org/smtpd.conf) like:

```diff
  ...
  listen on egress \
          tls pki <pki> \
          auth-optional \
          tag MTA
  ...
  action "local" maildir alias <aliases>
  ...
+ match tag MTA   from any                for domain "<fqdn>" action "local"
  ...
```

\#2. I set up default list settings.

```console
# nvim /usr/local/lib/mailman/Mailman/mm_cfg.py
```

```diff
  # Put YOUR site-specific settings below this line.
  ...
+ DEFAULT_URL_HOST = '<mail-server-fqdn>'
+ DEFAULT_EMAIL_HOST = '<mailing-list-domain>'
+ add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
```

Let's start the mailing list system:

```console
# rcctl -f -d start mailman
doing _rc_parse_conf
doing _rc_quirks
mailman_flags empty, using default >-s start<
doing _rc_parse_conf /var/run/rc.d/mailman
doing _rc_quirks
doing rc_check
mailman
doing rc_start
doing _rc_wait start
doing rc_check
Starting Mailman's master qrunner.
doing _rc_write_runfile
(ok)
```

Now you may operate lists via command line :)
The commands MailMan provides are [here](https://wiki.list.org/DOC/4.09%20Summary%20of%20the%20mailman%20bin%20commands).
For example, running `/usr/local/lib/mailman/bin/newlist <list-name>` will create your first list.

Have you decided to use Mailman?
If so, the last steps are registering cron jobs and enabling the daemon to let it start at boot.

```console
# crontab -u _mailman /usr/local/lib/mailman/cron/crontab.in
```

```console
# rcctl enable mailman
```

Thank you for your reading.
I hope you enjoy the networks :)