Mailman
From charlesreid1
A guide to installing GNU Mailman and getting it working with an Apache web server and a Postfix Mail Server.
Installation
You can download mailman from here: http://www.gnu.org/software/mailman/download.html
To verify the download using the signature, add the public keys of the developers listed on the download page, and visit Verifying a File using a Detached Signature at my GnuPG page for the verification process.
Pre-Configure Process
You must first create a group named "mailman" on your system, and create a user named "mailman" in the group "mailman".
# groupadd mailman # useradd --shell /no/shell --home-dir /no/home --gid mailman mailman
Configuration
For my configuration of mailman, I wanted to make a self-contained installation, including moving the /var/mailman
directory (which contains mutable mailman data) into the mailman installation directory. This is the reason for the --with-var-prefix
option.
#!/bin/sh
./configure \
--prefix=${HOME}/pkg/mailman/2.1.14 \
--with-var-prefix=${HOME}/pkg/mailman/var \
--with-cgi-gid=503
where the number coming after --with-cgi-gid
is the gid for the Apache (or whichever web server) group. In your Apache config file, there is a User and Group listed, which is the user and group that Apache is run as. A corresponding entry can be found in /etc/group
, something like:
apache:x:503:
This number is the gid for Apache, and in order to run cgi scripts, Mailman must run these scripts with this gid.
Before I ran configure, I had to run
$ mkdir -p ${HOME}/pkg/mailman/var $ /usr/bin/sudo -R chown mailman ${HOME}/pkg/mailman $ /usr/bin/sudo -R chgrp mailman ${HOME}/pkg/mailman $ /usr/bin/sudo -R chmod 02775 ${HOME}/pkg/mailman # <-- the "02" sets UID and GID permissions
(for more info on setting UID and GID permissions, see http://en.wikipedia.org/wiki/Setuid)
NOTE: I acknowledge that using --with-var-prefix
is more complicated, but the advantages are, (1) this keeps mailman self-contained, and (2) it is easy to upgrade mailman by installing the new version to ${HOME}/pkg/mailman/X.Y.Z
.
Once you've created this directory with the correct permissions, do the usual thing:
$ ./runconfigure.sh $ make -j2 $ /usr/bin/sudo -u mailman make install # <-- must be run as sudo because # creating/modifying directories # owned by "mailman" user
Checking/Fixing Permissions
It is likely you'll run into problems with the permissions, even if you're careful. However, this can be easily fixed using a mailman script:
# cd ${HOME}/pkg/mailman/2.1.14 # bin/check_perms (any permissions problems will be displayed here) # bin/check_perms -f (any permissions problems will be fixed)
(note that this must be run as the superuser, hence the #
's).
Connecting Mailman with Web Server
I'm using an Apache web server. To get Mailman working with Apache, I had to add the following to the httpd.conf
file to allow the mailman program to run cgi scripts:
# Add a script alias for mailman to run required cgi-scripts
ScriptAlias /mailman/ "/path/to/mailman/cgi-bin/"
<Directory "/path/to/mailman/cgi-bin">
AllowOverride None
Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
</Directory>
To add GNU icons, Python-Powered icons, and mailman icons, copy the mailman-provided icons into Apache's icons directory (usually in /path/to/apache/icons
):
$ cp /path/to/mailman/icons/*.{jpg,png} /path/to/apache/icons/.
Then you can point to these in the Mailman config file:
$ sudo vim /path/to/mailman/Mailman/mm_cfg.py
by adding the following line:
IMAGE_LOGOS = '/images/'
(default values for most stuff is defined in Defaults.py).
Setting Up Pipermail
Pipermail is a feature of Mailman that archives all of the mailing list's activity and makes it available to users. This is basically what's being put in /var/mailman
(or, in case you used the --with-var-prefix
configure option above, /path/to/mailman/var
).
This can be set up to be accessed via the web:
Alias /pipermail/ /path/to/mailman/var/archives/public/
<Directory /pipermail/>
Options FollowSymLinks
AddDefaultCharset Off # <-- if your list archives will
# contain international characters
AllowOverride None
Order deny,allow
Allow from all
</Directory>
Connecting Mailman with Mail Server
See Mail Server for details on how to set up a mail server.
I use postfix mail server.
In the Postfix configuration file main.cf
, the recipient_delimiter
setting should be:
recipient_delimiter = +
In /path/to/mailman/Mailman/mm_cfg.py, add the following line:
MTA = 'Postfix'
MTA is a directory containing instructions for Mailman when lists are created/removed.
Next, Defaults.py should contain the following:
POSTFIX_ALIAS_CMD = '/usr/sbin/postalias' POSTFIX_MAP_CMD = '/usr/sbin/postmap'
or, wherever your postalias and postmap binaries are located. If they are not, re-define them in mm_cfg.py.
Generate alias files by running the genaliases program:
$ cd /path/to/mailman $ bin/genaliases
This will create files in the var directory. These should be owned by mailman:
$ cd /path/to/mailman/var/data $ sudo chown mailman:mailman aliases* $ sudo chmod g+w aliases* $ ls -l -rw-rw---- 1 mailman mailman 368 2011-04-07 18:17 aliases -rw-rw---- 1 mailman mailman 12288 2011-04-07 18:17 aliases.db -rw-r--r-- 1 mailman mailman 10 2011-04-07 15:00 last_mailman_version -rw-r--r-- 1 mailman mailman 14100 2011-04-07 14:59 sitelist.cfg
Then the Postfix main.cf file should contain the following line to point to these aliases:
alias_maps = hash:/etc/aliases, hash:/home/charles/pkg/mailman/var/data/aliases
(/etc/aliases is included because this was the value of alias_maps before pointing it to mailman's aliases).
Mailman Cron Jobs
Mailman uses cron jobs to do routine tasks; these can be added by running
$ /usr/bin/sudo -u mailman crontab /path/to/mailman/cron/crontab.in
Mailing List Basics
Every new list will have a set of email addresses that can be used to interface with the mailing list.
For a list called mylist@example.com, you have these addresses:
- mylist@example.com - this is the email address people should use for new postings to the list.
- mylist-join@example.com - by sending a message to this address, a new member can request subscription to the list (both the subject and body of the message are ignored)
- mylist-subscribe@exmaple.com - alias for the -join address
- mylist-leave@example.com - request unsubscription from the list (both hte subject and the body are ignored)
- mylist-unsubscribe@example.com - alias for the -leave address
- mylist-owner@example.com - email the list owners and moderators directly
- mylist-request@example.com - emails the mail robot, which processes email commands that can be used to set member subscription options, as well as process other commands
- mylist-bounces@example.com - receives bounces from members whose addresses have become either temporarily or permanently inactive; the -bounces address is also a mail robot that processes bounces and automatically disables or removes members as configured in the bounce processing settings; any bounce messages that are either unrecognized, or do not seem to contain member addresses, are forwarded to the list administrators
- mylist-confirm@example.com - another email robot, which processes confirmation messages for subscription and unsubscription requests
New Mailing Lists
Creating New Mailing Lists
Web Interface
You can navigate to
http://www.website.com/mailman/listinfo
to view the available mailing lists, or
http://www.website.com/mailman/admin
to administer/create mailing lists.
Command-Line Interface
New mailing lists can be created from the command line by running:
/path/to/mailman/bin/newlist YourListNameHere
First Mailing List: The Site-Wide Mailing List
The first mailing list you create should be a site-wide mailing list, which is necessary for normal Mailman operations [1]. The name of this mailing list can be specified in mm_cfg.py
; it is mailman
by default.
/path/to/mailman/bin/newlist --urlhost=www.mywebsite.com --emailhost=mywebsite.com mailman
--url-host
and --email-host
can be set explicitly as above, or they can be defined using the variables DEFAULT_EMAIL_HOST and DEFAULT_URL.
Next, you can configure the site-wide mailing list using a template file; there is a generic template file for the site-wide mailing list in /path/to/mailman/var/data/sitelist.cfg
. These configuration options include things like whether recipients can get emails in daily batches or as-they-happen, whether the list is private or public, subscribe/unsubscribe options, etc.
This config file can be applied to an existing list by running
$ /path/to/mailman/bin/config_list -i /path/to/mailman/var/data/sitelist.cfg mailman