DEV Community

nabbisen
nabbisen

Posted on • Updated on • Originally published at obsd.solutions

Mailman mailing list on OpenBSD 6.7

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 server on OpenBSD.

Environment

  • OS: OpenBSD 6.7
  • MTA (Mail Transfer Agent): OpenSMTPD
  • Mailing List Server: GNU Mailman 2.1

Tutorial

The package manager is available and useful because it provides well-configured setting files as well as applications.
Just run:

# pkg_add mailman
Enter fullscreen mode Exit fullscreen mode

The result is:

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
Enter fullscreen mode Exit fullscreen mode

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

Then, edit the config file:

# # (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
Enter fullscreen mode Exit fullscreen mode

to add the lines in the end of the file:

  # Put YOUR site-specific settings below this line.
+ MAILMAN_GROUP = '_mailman'
+ MAILMAN_USER = '_mailman'
Enter fullscreen mode Exit fullscreen mode

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: '
Enter fullscreen mode Exit fullscreen mode
    uid = pwd.getpwnam(mm_cfg.MAILMAN_USER)[2]
KeyError: 'getpwnam(): name not found: '
Enter fullscreen mode Exit fullscreen mode

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

Site list is missing: mailman
Enter fullscreen mode Exit fullscreen mode

The detail is here in the official documentation.

Run the Mailman command:

# /usr/local/lib/mailman/bin/newlist mailman
Enter fullscreen mode Exit fullscreen mode

which is followed by:

Enter the email of the person running the list: <your@email.address>
Initial mailman password: 
Enter fullscreen mode Exit fullscreen mode
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...
Enter fullscreen mode Exit fullscreen mode

In order to follow the messages, edit it:

# nvim /etc/mail/aliases
Enter fullscreen mode Exit fullscreen mode

and run:

# newaliases
/etc/mail/aliases: xx aliases
Enter fullscreen mode Exit fullscreen mode

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

# usermod -G _mailmanq _smtpd
Enter fullscreen mode Exit fullscreen mode

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 like:

  ...
  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"
  ...
Enter fullscreen mode Exit fullscreen mode

#2. I set up default list settings.

# nvim /usr/local/lib/mailman/Mailman/mm_cfg.py
Enter fullscreen mode Exit fullscreen mode
  # 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)
Enter fullscreen mode Exit fullscreen mode

Let's start the mailing list system:

# 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)
Enter fullscreen mode Exit fullscreen mode

Now you may operate lists via command line :)
The commands MailMan provides are here.
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.

# crontab -u _mailman /usr/local/lib/mailman/cron/crontab.in
Enter fullscreen mode Exit fullscreen mode
# rcctl enable mailman
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)