In this tutorial I will configure a virtual host with the hostname lists.example.com where I will install Mailman. lists.example.com is also the right part of the mailing list email addresses that will be configured in Mailman, i.e., mails to a mailing list will have to be sent to the address <listname>@lists.example.com.
As your hostname will be different, please adjust this tutorial accordingly. Also make sure that your hostname exists in DNS.
Mailman can be used with many mail servers (e.g. Postfix, Exim, Sendmail, Qmail). I will use Postfix in this tutorial. Make sure you have a working Postfix installation.
Installing Mailman And Apache
As Mailman comes with a web frontend, thus need a web server in addition to Mailman. I choose Apache. Mailman and Apache can be installed as follows:
1 |
apt-get install mailman apache2 |
Mailman needs a so-called “site list”, which is the list from which password reminders and such are sent out from. This list needs to be created before mailman will start. To create the list, run
1 |
newlist mailman |
and follow the instructions on-screen. Note that you also need to start mailman after that, using
1 |
/etc/init.d/mailman start |
Mailman comes with an Apache configuration file, /etc/mailman/apache.conf
, which we copy to /etc/apache2/sites-available/mailman.conf
:
1 |
cp /etc/mailman/apache.conf /etc/apache2/sites-available/mailman.conf |
Open /etc/apache2/sites-available/mailman.conf
1 |
vi /etc/apache2/sites-available/mailman.conf |
… and append the following vhost configuration to the file (there’s already a vhost for lists.example.net in the file which is commmented out – please don’t use that vhost as my vhost configuration differs a little bit although it looks quite similar):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[...] <VirtualHost *:80> ServerName lists.example.com DocumentRoot /var/www/lists ErrorLog /var/log/apache2/lists-error.log CustomLog /var/log/apache2/lists-access.log combined <Directory /var/lib/mailman/archives/> Options FollowSymLinks AllowOverride None </Directory> Alias /pipermail/ /var/lib/mailman/archives/public/ Alias /images/mailman/ /usr/share/images/mailman/ ScriptAlias /admin /usr/lib/cgi-bin/mailman/admin ScriptAlias /admindb /usr/lib/cgi-bin/mailman/admindb ScriptAlias /confirm /usr/lib/cgi-bin/mailman/confirm ScriptAlias /create /usr/lib/cgi-bin/mailman/create ScriptAlias /edithtml /usr/lib/cgi-bin/mailman/edithtml ScriptAlias /listinfo /usr/lib/cgi-bin/mailman/listinfo ScriptAlias /options /usr/lib/cgi-bin/mailman/options ScriptAlias /private /usr/lib/cgi-bin/mailman/private ScriptAlias /rmlist /usr/lib/cgi-bin/mailman/rmlist ScriptAlias /roster /usr/lib/cgi-bin/mailman/roster ScriptAlias /subscribe /usr/lib/cgi-bin/mailman/subscribe ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/ ScriptAlias / /usr/lib/cgi-bin/mailman/listinfo </VirtualHost> |
The second to last line ScriptAlias / /usr/lib/cgi-bin/mailman/listinfo
is optional; it makes that when you go to http://lists.example.com/, you will be redirected to http://lists.example.com/listinfo. This makes sense if you don’t have any files to serve in the document root /var/www/lists
.
Next create the document root /var/www/lists
, enable the lists.example.com vhost configuration and restart Apache:
1 2 3 |
mkdir /var/www/lists a2ensite mailman.conf /etc/init.d/apache2 restart |
Because we are using a vhost here (lists.example.com), we need to adjust the following variables in /etc/mailman/mm_cfg.py
:
1 |
vi /etc/mailman/mm_cfg.py |
1 2 3 4 5 6 7 |
[...] DEFAULT_URL_PATTERN = 'http://%s/' [...] DEFAULT_EMAIL_HOST = 'lists.example.com' [...] DEFAULT_URL_HOST = 'lists.example.com' [...] |
Configuring Postfix
Now we need to configure Postfix. First run:
1 2 |
postconf -e 'relay_domains = lists.example.com' postconf -e 'mailman_destination_recipient_limit = 1' |
Then open /etc/postfix/master.cf
1 |
vi /etc/postfix/master.cf |
… and make sure you have the following lines in it (they should be there by default):
1 2 3 4 5 |
[...] mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} [...] |
Next we must associate the lists.example.com domain to the mailman: transport. How you do this depends on your Postfix configuration. Transports can be stored in a MySQL database or, like in most setups, the file /etc/postfix/transport
is used for creating transports. Both cases are described below
Transports In A MySQL Database
To create the necessary transport, log into MySQL…
1 |
mysql -u root -p |
… and run the following MySQL commands:
1 2 3 |
USE mail; INSERT INTO `transport` (`domain`, `transport`) VALUES ('lists.example.com', 'mailman:'); quit; |
Restart Postfix afterwards:
1 |
/etc/init.d/postfix restart |
Transports In /etc/postfix/transport
If you don’t have your transport in a MySQL database, you probably use the file /etc/postfix/transport. In this case you can set up the necessary transport as follows:
1 |
postconf -e 'transport_maps = hash:/etc/postfix/transport' |
Open /etc/postfix/transport
1 |
vi /etc/postfix/transport |
1 |
lists.example.com mailman: |
Run
1 |
postmap -v /etc/postfix/transport |
afterwards and restart Postfix:
1 |
/etc/init.d/postfix restart |
Creating The mailman Mailing List
Before we can start to use Mailman, we must create a mailing list called “mailman”; this is obligatory – without it Mailman won’t start:
1 |
newlist --urlhost=lists.example.com --emailhost=lists.example.com mailman |
In most cases the –urlhost and –emailhost switches are not necessary because our vhost is already named lists.example.com, and we also have it in /etc/mailman/mm_cfg.py (DEFAULT_EMAIL_HOST and DEFAULT_URL_HOST), but if you want to go sure that Mailman uses the correct hostname, use these switches.
1 |
newlist --urlhost=lists.example.com --emailhost=lists.example.com mailman |
Enter the email of the person running the list: <– specify the list administrator email address Initial mailman password: <– mailman_password
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:
1 2 3 4 5 6 7 8 9 10 11 |
## mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman" |
Hit enter to notify mailman owner… <– ENTER
Now open /etc/aliases and add the aliases that you see in the output of the newlist command (this has to be done manually for each new list that you create):
1 |
vi /etc/aliases |
1 2 3 4 5 6 7 8 9 10 11 12 |
[...] ## mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"</pre> |
Whenever you modify /etc/aliases, you need to run
1 2 |
# newaliases # /etc/init.d/postfix restart |
afterwards.
Now we can finally start Mailman:
1 |
/etc/init.d/mailman start |