Tag Archives: mailman

Mailman with lighttpd and Postfix on Gentoo

This post details how to setup mailman using lighttpd and postfix on gentoo.

Before starting I assume that you have:
* Lighttpd setup and working
* Postfix setup to handle mail from one domain
* MX records setup for the subdomain you want to use for lists

First, we need to install mailman, but before we do that we need to make sure it uses the right UID and GID (lighttpd) instead of apache, which is the default. To do this append

MAILMAN_CGIGID="lighttpd"
MAILMAN_CGIUID="lighttpd"

to /etc/make.conf and then proceed to install mailman:

# emerge mailman

Now it’s time to configure lighttpd. This we do by adding the following to /etc/lighttpd/lighttpd.conf:

alias.url += (
          "/services/mailman/mailman-icons" => "/usr/lib64/mailman/icons/",
          "/services/mailman/pipermail" => "/var/lib/mailman/archives/public/",
          "/services/mailman" => "/usr/lib64/mailman/cgi-bin/",
)

$HTTP["url"] =~ "^/services/mailman" {
        cgi.assign = (
                "/admin" => "",
                "/admindb" => "",
                "/confirm" => "",
                "/create" => "",
                "/edithtml" => "",
                "/listinfo" => "",
                "/options" => "",
                "/private" => "",
                "/rmlist" => "",
                "/roster" => "",
                "/subscribe" => "")
        server.indexfiles = ("listinfo", "index.html")
}
$HTTP["url"] =~ "^/services/mailman/pipermail/" {
             dir-listing.activate = "enable"
             dir-listing.hide-dotfiles = "enable"
             server.follow-symlink = "enable"
}

I choose not to serve mailman from a vhost, if you want to do that you’ll need to change the above accordingly. Otherwise you’ll just have to change the url matches and aliases to reflect from where you want to host mailman. You will also need to make sure that the alias and cgi modules are enabled (located at the top of lighttpd.conf).

The next thing to configure is mailman itself. Append the following to /etc/mailman/mm_cfg.py:

MTA = 'Postfix'
DEFAULT_EMAIL_HOST = 'lists.example.tld'
DEFAULT_URL_HOST = 'example.tld' 
DEFAULT_URL_PATTERN = 'http://%s/services/mailman/' 
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST) 
IMAGE_LOGOS = '/services/mailman/mailman-icons/' 

POSTFIX_STYLE_VIRTUAL_DOMAINS = [DEFAULT_EMAIL_HOST]

PUBLIC_ARCHIVE_URL = 'http://%(hostname)s/services/mailman/pipermail/%(listname)s'

You should set DEFAULT_EMAIL_HOST to the subdomain you want your lists to use, DEFAULT_URL_HOST to the host from which you will serve the mailman web pages, and change DEFAULT_URL_PATTERN, IMAGE_LOGOS, PUBLIC_ARCHIVE_URL so that they are consistent with your settings in lighttpd.conf. The call to add_virtualhost is need when you change either of the _HOST variables like this.

Continuing, there is a few things we need to do as the mailman user. First install the cron jobs:

# su - mailman
mailman $ cd cron
mailman $ crontab crontab.in
mailman $ cd ..

Then set the site password:

mailman $ bin/mmsitepass

The site password works instead of any other password in the mailman installation, and is used to adminstrate it.

Next we create the site-wide mailing list, which is needed for proper operation of mailman:

mailman $ bin/newlist mailman

And logout from the mailman account and continue…

…with configuring postfix. This is as simple as adding the following two lines to /etc/postfix/main.cf:

virtual_alias_domains = lists.example.tld
virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman

Once again replacing lists.example.tld with the subdomain you want your lists to use.

Now we only need to reload postfix, start mailman and add it to the default runlevel:

# /etc/init.d/postfix reload
# /etc/init.d/mailman start
# rc-update add mailman default

Congratulations, you should now have a working mailman install!