Kolab2 Integration with mailman

From Kolab Wiki

Revision as of 10:19, 14 October 2008 by Dervanil (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This is a small howto on using Mailman with Kolab. This was tested on a debian testing running Mailman 2.1.7 and Kolab 2.0.3, but I think this howto should be easily adaptable to other distros.

General information about Mailman integration with Postfix can be found here: http://homex.subnet.at/~max/mail/mailman.php


Contents

Postfix Configuration

To not adapt your aliases files for every new created mailing we add a new file in /kolab/etc/postfix/virtual-regexp. containing the following:

/^(postmaster|root|abuse)@list\.cerdd\.org$/   listmaster at cerdd.org
/^([-a-zA-Z0-9_]+)-(post|bounces|admin|request|owner|on|off|subscribe|unsubscribe)@list\.cerdd\.org$/ mailman-$2+$1
/^([-a-zA-Z0-9_]+)@list\.cerdd\.org$/ mailman-post+$1

Of course you should replace the domain part with your own :)

Now you need to configure postfix to make use of this file. So you need to do some changes in /kolab/etc/kolab/templates/main.cf.template

Apend the follwing to the line starting with virtual_maps. regexp:/kolab/etc/postfix/virtual-regexp. After that this line should look like this:

virtual_maps =  hash:/kolab/etc/postfix/virtual, ldap:ldapdistlist, ldap:ldapvir
tual, regexp:/kolab/etc/postfix/virtual-regexp

At last you need some aliases in /kolab/etc/postfix/aliases

mailman-post: "|/var/lib/mailman/mail/mailman post $EXTENSION"
mailman-admin: "|/var/lib/mailman/mail/mailman admin $EXTENSION"
mailman-request: "|/var/lib/mailman/mail/mailman request $EXTENSION"
mailman-owner: "|/var/lib/mailman/mail/mailman owner $EXTENSION"
mailman-on: "|formail -I'Subject: subscribe'|/var/lib/mailman/mail/mailman mailcmd $EXTENSION"
mailman-off: "|formail -I'Subject: unsubscribe f'|/var/lib/mailman/mail/mailman mailcmd $EXTENSION"
mailman-bounces: "|/var/lib/mailman/mail/mailman bounces $EXTENSION"
mailman-confirm: "|/var/lib/mailman/mail/mailman confirm $EXTENSION"
mailman-join: "|/var/lib/mailman/mail/mailman join $EXTENSION"
mailman-leave: "|/var/lib/mailman/mail/mailman leave $EXTENSION"
mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe $EXTENSION"
mailman-unsubscribe: "|/var/lib/mailman/mail/wrapper unsubscribe $EXTENSION"

After editing this file You need to refresh your aliases db by runnig the postalias command "/kolab/sbin/postalias /kolab/etc/postfix/aliases".

Mailman config for Kolab

Now you have done all prequisits to give your mailman a run, but unfortunately we need to treat the mailman wrapper a little bit as he assumes that he is run be an user with the guid of "deamon". This may differ in your distro but this is the default here on the debian system. Since postfix is run as kolab-n the wrapper won't do his work :(.

Now we have two options:

  • 1. change the uid of postfix to the expected value of the wrapper (depreciated)
  • 2. change the wrapper in the way the he expects to be run by kolab-n

The first method is depreciated as this might affect the whole kolab installation, so lets focus on the second one.

The guid thing is compiled into the wrapper so we need to compile a new version. Get your copy of the mailman sources from http://www.gnu.org/software/mailman/download.html

To comile your version with the correct values start your ./configure script with some options:

./configure --with-username=list --with-groupname=list --with-mail-gid=kolab-n --without-permcheck --prefix=/var/lib/mailman --with-cgi-gid=kolab-n

After that do make (not make install!!!). If all goes well there should be a new version of the mailman binary in the src-folder in the mailman dir. Take this binary and replace it with the existing file of your installation. On debian this is located in /var/lib/mailman/mail/.

Apache config

When using the Apache Webserver provided with the Kolab distribution, there are some paths needed to be added. They should go in the file "/kolab/etc/kolab/templates/httpd.conf.template". I added mine after the original cgi-bin configuration (around line 200):

ScriptAlias /mailman/       /var/lib/mailman/cgi-bin/

<Directory /var/lib/mailman/cgi-bin/>
   AllowOverride None
   Options ExecCGI
   AddHandler cgi-script .cgi
   Order allow,deny
   Allow from all
</Directory>

Alias /pipermail/ /var/lib/mailman/archives/public/
Alias /archives/ /var/lib/mailman/archives/public/

<Directory /var/lib/mailman/archives/public/>
   Options Indexes FollowSymlinks
   AllowOverride None
   Order allow,deny
   Allow from all
   AddDefaultCharset Off
</Directory>

Adjusting Defaults for Mailman

To adjust your mailman installation to your local settings, you need to edit the file "/var/lib/mailman/Mailman/mm_cfg.py". For the possibe options you can refer to the file "Defaults.py" inside the same dir. I change the hostname for the mailinglist, some minor adjustmends for new lists and added a "X-Spam-Flag: Yes" header check to the default Spam rules:

DEFAULT_EMAIL_HOST = 'list.cerdd.org'
DEFAULT_URL_HOST = 'list.cerdd.org'
DEFAULT_URL_PATTERN = 'http://%s/mailman/'

PUBLIC_ARCHIVE_URL = 'http://%(hostname)s/archives/%(listname)s'
DEFAULT_ARCHIVE_PRIVATE = 1

DEFAULT_BOUNCE_MATCHING_HEADERS = """
# Lines that *start* with a '#' are comments.
to: friend@public.com
message-id: relay.comanche.denmark.eu
from: list@listme.com
from: .*@uplinkpro.com
X-Spam-Flag: Yes
"""

Final steps

Now your setup is complete and you can give your mailman a test. Please examine your log files to verify that all os configured right.

Additional Steps

I created a List for all my Kolab-Users and added a cron job to sync my users to my list:

#!/bin/bash
#
# Little Helper to sync all KNUT2 Users
# to a Mailing-List
#
# Be careful: No exception handling!!!!
#
# by Kai Wilken, kai.wilken@cillawigs.de
# 2008/10/13
#

# Change to the DN, where your users are located.
# the whole subtree is listed
LDAP_USER_DN="ou=user,dc=you-domain,dc=org"

# Option for sync_members. Run the script without arguments to get help on the values
MM_SYNC_OPTS="-w=no -g=no -d=no -a -f"
MM_SYNC_LIST="YOUR_LISTNAME"

# I know, quick and dirty. But it works.
TEMP_FILE="/tmp/mm_sync"

# Get the list of kolab users from ldap
/kolab/bin/ldapsearch -b $LDAP_USER_DN | /bin/grep "mail: " | /usr/bin/awk {'print substr($0, 7) '} > $TEMP_FILE

# run the sync_members script
/var/lib/mailman/bin/sync_members $MM_SYNC_OPTS $TEMP_FILE $MM_SYNC_LIST

# remove the temp-file
rm $TEMP_FILE
Personal tools