Mailing Lists with Couriermlm

Courier not only is an excellent mail server, it also ships with a mailing list manager that can be used to build mailing lists without relying on a third party provider (which usually has the bad habit of adding advertising text to the emails being forwarded).

Here’s a small tutorial that explains how to set up a new mailing list using couriermlm.

I’m using a very simple Courier setup where email accounts are equivalent to system users and are authenticated through authpam. If you use Courier with user accounts authenticated against a MySQL database or something else, you might have to do things differently.

1. Create a new User

You could theoretically create all mailing lists under a common system user and use aliases to deliver email to the mailing list folders. I found it easier to create a dedicated user account for each mailing list, however. This way, I don’t have to modify system-wide courier configuration files for each mailing list and all informations and configuration belonging to a mailing list contained in the dedicated user’s home directory.

Assuming you wanted to create a new mailing list called xyzzyx to which users could post by sending emails to xyzzyx@server.com, create a user account like this:

useradd \
  --comment "User account for the Xyzzyx mailing list" \
  --home-dir /home/xyzzyx \
  --gid users \
  --create-home \
  --shell /sbin/nologin \
  --no-user-group \

Notice that I haven’t allowed this user to login. One angle of attack less that you need to worry about.

2. Create the Mailing List

To make sure the mailing list belongs to the right user, impersonate the user when you set up the mailing list:

su --shell /bin/bash xyzzyx
cd ~

Now use the couriermlm tool to create a new mailing list. I literally named the directory for the mailing list "MailingList" because (as explained above) I’m using a dedicated system user per mailing list, so this is the only mailing list that will ever be on the user’s home directory.

couriermlm create /home/xyzzyx/MailingList ADDRESS=xyzzyx@server.com

3. Process Mails with Couriermlm

Now comes the tricky part. Any emails sent to xyzzyx@server.com need to be processed with couriermlm. I found some advice in Jim Gifford’s How to Setup the Extra Capabilities in Courier hints. Combined with the dot-courier documentation, which states:

In addition to receiving mail addressed user@domain, it is also possible for user to receive mail addressed to user-foo@domain, for arbitrary values of foo. To do this, install $HOME/.courier-foo, with delivery instructions for mail addressed to user-foo@domain.


The file $HOME/.courier-foo-default specifies delivery instructions for any user-foo-bar@domain address, where bar can be anything. However, it does NOT control mail delivery to user-foo@domain, which is controlled by $HOME/.courier-foo.

I came up with these three files:

# For normal messages (xyzzyxserver.com)
echo "| couriermlm msg /home/xyzzyx/MailingList" > .courier
# For control messages (eg. xyzzyx-subscribe@server.com)
echo "| couriermlm ctlmsg /home/xyzzyx/MailingList" > .courier-default
# Declare which user owns this mailing list (for administrative contact)
echo "me@server.com" > .courier-owner

Those mangled >s should, of course, be actual ‘>’ (greater-than) characters, but my syntax highlighter escapes them for some reason!

4. Set Up Cron Jobs

Finally, for sending out email digests, bounce test manages and general book-keeping, couriermlm requires to cron jobs to be set up.

One is run hourly. If you’re using vixie-cron, simply create a new shell script at /etc/cron.hourly/xyzzyx-hourly.sh with the following contents:


# /etc/cron.hourly/xyzzyx-hourly.sh
couriermlm hourly /home/xyzzyx/MailingList

And another at /etc/cron.daily/xyzzyx-daily.sh:


# /etc/cron.daily/xyzzyx-daily.sh
couriermlm daily /home/xyzzyx/MailingList

That’s it. Couriermlm also has a web interface that you can enable for your users. You can also change or translate the templates for any emails sent out by couriermlm (liike lost password lookups, bounce warnings, subscription confirmations and more) by editing the .tmpl files in the MailingList directory you created in step 2.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please copy the string HHgnPU to the field below:

Social Widgets powered by AB-WebLog.com.