Software selected

It's all about choices. Open Source / Libre software often has simalar projects with slight differences in emphasis; my selection of software might not be right for your site. If you think Ubuntu + Postfix + Mailman is right for you, great. Or if you can pick any helpful information from this page and apply it to your software selection, great. Otherwise, sorry to have wasted your time.

Why Ubuntu?

After I abandoned Windows I settled on Red Hat for quite a while. It helped to have a relative who worked for the company (free tech support!) I've poked around with other distributions here and there and found some nice things in each. Here and there I seriously considered switching to SuSE (now SUSE from Novell) and Mandrake (now Mandriva) -- each was a slick distribution, but each had some things which were annoyingly different than what I was used to, i.e. the Red Hat way.

Eventually the folks at Red Hat decided to put all their eggs in their professional line and spun off the personal version as Fedora Core. Fedora was and is still a great distribution, but I started feeleing a bit like a guinnea pig for Red Hat Enterprise. It was time to go shopping again. Fedora Core has come a long way since I left the Red Hat camp; I've been reading great stuff about the recent releases. By now, of course, I'm used to the Debian/Ubuntu way. Such is life.

Ubuntu turned out to have a lot of things I liked -- a strong freeware mentality, active user support, rapid response to security flaws, nice fit-and-finish. Package control is extremely easy with apt-get and/or Synaptic.

Why Mailman?

The Mailman has a nice collection of features -- web-based controls for both users and administrators, lots of configuration options, good spam controls. This one package can provide you with hidden mailing lists just for your friends and public lists to which anyone who visits your site can subscribe.

One great feature of Mailman is the ability to assign others to keep track of mailing lists without giving them enough power to trash your entire system.

Let's get started.

Install

If you don't have at least Postfix and MySQL installed as described here, stop. I'm describing a non-standard install. You might want to follow these instructions instead.

There is only one package you'll need to add - mailman. Use Synaptic Package Manager or apt-get to add it to your machine.

Your computer will have a new user - list - and a new group - list - and many files in the following directories:
/usr/lib/mailman/
/usr/lib/cgi-bin/mailman/
/usr/share/doc/mailman/
/usr/log/mailman/
/var/lib/mailman/
/var/lock/mailman/
/var/run/mailman/
/etc/mailman/
/etc/init.d/
/usr/sbin/

It's my belief the Ubuntu install files leave you with the wrong file ownerships, so if you haven't already opened a terminal window do so and become root$ sudo -s (and enter your password)
Mailman includes a handy script to make check your permissions. It's in /usr/sbin/ so it should be on root's path.# check-perms
- and note the massive problems. To fix permissions,# check-perms -f
A bunch of changes scroll by, but did it get them all?# check-perms -f
Nope; still errors. In fact, you need to# cd /var/lib/mailman
# chown list:list *

Configure

Of course I'm using example.com for this HOWTO. Substitute your own domain name.

Mailman configuration files

The Mailman configuration files are in /etc/mailman. Use your favorite text editor to edit /etc/mailman/mm_cfg.py. You'll want to check/edit/add the following lines:MTA=None # No MTA processing req'd for Ubuntu/virtual/postfix-to-mailman.py

IMAGE_LOGOS = '/mmimages/'

DEFAULT_EMAIL_HOST = 'example.com'
DEFAULT_URL_HOST = 'example.com'

I'm not sure if you need this line - can someone tell me?DEB_LISTMASTER = 'postmaster@example.com'

Note: Some versions of Ubuntu (and Debian) may also require a single-character in /etc/postfix/master.cf in order to give Mailman the permissions it needs. If your version of this file has a line that looks like this:mailman unix - - n - - pipe
change it to this:mailman unix - n n - - pipe
See Debian bug 315939
Thanks to Lars Rahm at the American Overseas School of Rome for pointing this out.

Apache2 configuration files

Apache 2 config files are in /etc/apache2. The Apache authors think you should put anything that looks like a module in mods-available and mods-enabled. Go ahead and create a new file: /etc/apache2/mods-available/mailman.conf

Optional - pipermail is one of those directory names which hangs around for historical reasons but makes little sense to users. You might want to add a more sensible-sounding alias for the mailing list archives.Alias /archives/ /var/lib/mailman/archives/public/
<Directory /var/lib/mailman/archives/public>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Now add a symlink to this file so Apache will use your new Mailman aliases the next time it starts:# cd /etc/apache2/mods-enabled
# ln -s /etc/apache2/mods-available/mailman.conf mailman.conf

Postfix configuration files

Configuration files for Postfix are in /etc/postfix. For a change, there are a couple files to edit in this directory.

Let's start by creating a new file, /etc/postfix/transport, which contains one line:lists.example.com mailman:

What we've just done is create a fake computer name - lists.example.com - which we can use to help Postfix sort mailing list messages from normal emails. This will be a hash, so as root:# cd /etc/postfix
# postmap transport
(There now should be a file named transport.dd in the directory.) Mailman is a stock transport type which your copy of Postfix should already be configured to handle. To make sure this is the case check /etc/postfix/master.cf and confirm that it contains:mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}

Finally edit /etc/postfix/main.cf - add these three lines to the end of the file:relay_domains = lists.example.com
transport_maps = hash:/etc/postfix/transport
mailman_destination_recipient_limit = 1

Create your first list

Mailman doesn't have anything to do until there is at least one list for it to act on, so let's make one:# newlist mailman
You'll be asked for an administrator email address - give it yours - and a password. If all goes well you should immediately get an email welcoming you to your new list. The email will have a URL where you can go and experiment with the web-based mailman configuration. There's just one thing that won't work -- emails sent to the list will not work. On to the final section of this howto.

Adding MySQL aliases

If you've installed phpmyadmin as Ivar suggests you can use a GUI interface, otherwise you'll edit your MySQL database through the command line. Insert the following entries into the aliases table of the maildb database:

mail

destination

mailman@example.com

mailman@lists.example.com

mailman-admin@example.com

mailman-admin@lists.example.com

mailman-bounces@example.com

mailman-bounces@lists.example.com

mailman-confirm@example.com

mailman-confirm@lists.example.com

mailman-join@example.com

mailman-join@lists.example.com

mailman-leave@example.com

mailman-leave@lists.example.com

mailman-owner@example.com

mailman-owner@lists.example.com

mailman-request@example.com

mailman-request@lists.example.com

mailman-subscribe@example.com

mailman-subscribe@lists.example.com

mailman-unsubscribe@example.com

mailman-unsubscribe@lists.example.com

Your 'mailman' list should be operational.

Important step: please check your system against one or more of the available open relay test sites available on the web. For example: http://www.antispam-ufrj.pads.ufrj.br/cgi-bin/test-relay.cgi will try a number of common spammer methods to try to trick your system into forwarding a test message. You can view the tests in progress by watching tail -f /var/log/mail.log after you enter your IP address. (You will need to temporarily disable the smtpd_recipient_limit line in your /etc/postfix/main.cf to enable all the tests.)

Resources

I can't recommend one of these books over the other. The Dent book has good reference material in Apendicies A and B. The Hildebrandt/Koetter book is almost twice as thick and includes many examples and code snippets. Take your pick.

This is Ivar Abrahamsen's HOWTO for setting up a MySQL-based mail system for multiple domains and many users. If you don't need a setup as complex as his example, you won't need to do all the stuff I'm suggesting either.

Expliots and bugs are not just for Windows users, so you need to keep up-to-date on vulnerabilities and updates for your system. I frequently visit LWN (formerly Linux Weekly News) - I like that the editors there have relatively few axes to grind. You can view LWN for free, but they're subscription based -- consider throwing some money at them.