Table of Contents

Setup Mailman

This HowTo explains setting up Mailman for adminstration of mailinglists.

Installation of Mailman

At first, install the needed package:

# apt-get update && apt-get install mailman

Edit Mailman's config

In /etc/mailman/mm_cfg.py you have to set the following values like this:

DEFAULT_URL_PATTERN = 'http://%s/'
DEFAULT_EMAIL_HOST  = 'yourdomain.com'        <-- insert your hostname here
DEFAULT_URL_HOST    = 'lists.yourdomain.com'  <-- dito

and you have to enable Postfix as MTA:

MTA=Postfix

At the end of /etc/mailman/mm_cfg.py add something like this:

#-------------------------------------------------------------
# Postfix virtual domains, Mailman should update
POSTFIX_STYLE_VIRTUAL_DOMAINS = ['yourdomain.com','anotherdomain.org']

You have to specify in this variable every domain you want to use for mailing lists.

Display your Postfix configuration:

postconf | grep my

and check if $myorigin is part of $mydestination. If it is, then you can skip the next point. If it is not, then you need the following fix to get it working…

Create the localPostfix MTA

You only need this fix if $myorigin is not part of $mydestination in your Postfix configuration; if it is, just skip this point!

We will create the localPostfix MTA out of the Postfix MTA. So first copy:

# cd /usr/lib/mailman/Mailman/MTA/
# cp Postfix.py localPostfix.py

Then modify the newly created MTA:

def _addvirtual(mlist, fp):
    ...
    # Set up the mailman-loop address
    loopaddr = Utils.get_site_email(mlist.host_name, extra='loop')
    loopdest = '%s@localhost' % Utils.ParseEmail(loopaddr)[0]         <-- add: '%s@localhost' %
    ...
    # Now add all the standard alias entries
    for k, v in makealiases(listname):
        fqdnaddr = '%s@%s' % (k, hostname)
        localaddr = '%s@localhost' % k                                <-- add this line
        # Format the text file nicely
        print >> fp, fqdnaddr, ((fieldsz - len(k)) * ' '), localaddr  <-- change k to localaddr
    # Finish the text file stanza
    ...
def _check_for_virtual_loopaddr(mlist, filename):
    loopaddr = Utils.get_site_email(mlist.host_name, extra='loop')
    loopdest = '%s@localhost' % Utils.ParseEmail(loopaddr)[0]         <-- add: '%s@localhost' %

And finally enable it in /etc/mailman/mm_cfg.py:

MTA=localPostfix

Create the default mailing list

Mailman requires a default mailing list called mailman. This creates the files /var/lib/mailman/data/aliases and /var/lib/mailman/data/virtual-mailman. So type:

# newlist mailman
  Enter the email address of the person running the list: you@yourdomain.com
  Initial mailman password:
  Hit enter to notify mailing owner...

The email address should be yours. Later you should subscribe to this site list. The notification mail will only be sent once mailman is started.

Now configure your site list. There is a convenient template for a generic site list in the installation directory which can help you with this. The template can be applied to your site list by running:

# config_list -i /var/lib/mailman/data/sitelist.cfg mailman

Check Mailman's permissions

Before starting Mailman, it is wise to check the permissions.

# check_perms

If you encounter some warnings, you can fix them by running:

# check_perms -f

There may still be some wrong GIDs in /var/lib/mailman, so if you still get warning from check_perms after running it with -f type:

# cd /var/lib/mailman
# chgrp list -R bin cgi-bin cron icons locks logs mail Mailman pythonlib scripts templates

Create the site password

The first is the site password which can be used anywhere a password is required in the system. The site password will get you into the administration page for any list, and it can be used to log in as any user. Think root for a Unix system, so pick this password wisely! To set the site password, use this command:

# mmsitepass

The second password is a site-wide list creator password. You can use this to delegate the ability to create new mailing lists without providing all the privileges of the site password. Of course, the owner of the site password can also create new mailing lists, but the list creator password is limited to just that special role. To set the list creator password, use this command:

# mmsitepass -c

It is okay not to set a list creator password, but you probably do want a site password.

Start Mailman

Now we are able to start Mailman.

# /etc/init.d/mailman start

Your notification mail is sent.

Integrate Mailman with Postfix

In /etc/postfix/main.cf apply the following changes:

alias_maps              = hash:/etc/aliases,                          <-- add comma
                          hash:/var/lib/mailman/data/aliases          <-- add this line

...

local_recipient_maps    = unix:passwd.byname $alias_maps              <-- change $alias_database back to default $alias_maps

...

virtual_alias_maps      = hash:/etc/postfix/ispcp/aliases,            <-- add comma
                          hash:/var/lib/mailman/data/virtual-mailman  <-- add this line

...

# Mailman parameters                                                  <-- add this line
unknown_local_recipient_reject_code = 550                             <-- dito
owner_request_special               = no                              <-- dito
mailman_destination_recipient_limit = 1                               <-- dito

Reload the Postfix daemon:

# /etc/init.d/postfix reload

Configuration of the web interface

Mailman is controlled over a web interface. It's run on the apache webserver, so we have to add a new vhost there. Create the file /etc/apache2/sites-available/02_mailman.conf and insert the following:

<VirtualHost xxx.xxx.xxx.xxx:80>                                                   <-- insert your IP here
        ServerAdmin     webmaster@yourdomain.com                                   <-- insert your domain here
        DocumentRoot    /usr/lib/cgi-bin/mailman/

        DirectoryIndex  listinfo index.html
        
        ServerName      lists.yourdomain.com                                       <-- dito

        ErrorLog        /var/log/apache2/lists.yourdomain.com-error.log            <-- dito
        CustomLog       /var/log/apache2/lists.yourdomain.com-access.log combined  <-- dito

        Alias /pipermail /var/lib/mailman/archives/public/
        Alias /images/mailman /usr/share/images/mailman/

        <Directory /var/lib/mailman/archives/>
                Options Indexes FollowSymLinks
                AllowOverride None
        </Directory>

        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
</VirtualHost>

Now activate the new vhost:

# a2ensite 02_mailman.conf

After all this, you have to reload the apache configuration:

# /etc/init.d/apache2 reload

Create a mailing list

Now you can create a mailing list from the command line (or the web interface if you prefer):

# newlist --emailhost=yourdomain.com
  Name of the mailing list: test
  Enter the email address of the person running the list: you@yourdomain.com
  Initial mailman password: 
  Hit enter to notify mailing owner...

Attention: Mailman identifies mailing lists only with the part in front of the @-sign. So you can't create two lists test@abc.com and test@xyz.com, Mailman will only accept one test-list. You'll see that mailman handles these lists without the domain ending.

Administration

You can administrate your mailing lists now on:

See also

For more information, have a look at: