License

Copyright (C) 2008-2021 Oliver Bohlen.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

A copy of the license is included in the section entitled "GNU Free Documentation License".

Introduction

This documentation comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Howto: Mailinglists with MailMan for Gentoo Linux

Here a little description how you can create Mailinglists in an easy way.
You have to insert the specific lines into your Webserver configuration for easy Web-Administration. See the Webserver topic for this.
After installing MailMan you have to create an admin password with

/usr/lib/mailman/bin/mmsitepass

Put mailman into the nobody group
usermod -G cron,mailman,nobody mailman

and you have to set the correct permissions for postfix
/usr/lib/mailman/bin/check_perms -f

Create the MailMan cron jobs with
su - mailman -c 'crontab cron/crontab.in'

Create initial MailMan list:
/usr/lib/mailman/bin/newlist mailman
/usr/lib/mailman/bin/config_list -i /var/lib/mailman/data/sitelist.cfg mailman

If you want to use this solution you need the following howto(s) finished:

Required software

The required software has to be installed with the following command(s):
emerge net-mail/mailman

Changes in /etc/mailman/mm_cfg.py

File permissions:
Owner: mailman
Group: mailman
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/mailman/mm_cfg.py

Changed on 18.03.09
Issued by olli
Beginning line 54

Some Settings for MailMan environment

MTA = 'Postfix'
DEFAULT_EMAIL_HOST = 'example.com'
DEFAULT_URL_HOST   = 'mailman.example.com'
DEFAULT_URL_PATTERN = 'https://%s/mailman/'
add_virtualhost('mailman.example.com')
POSTFIX_STYLE_VIRTUAL_DOMAINS =  ['example.com']
DEFAULT_ARCHIVE_PRIVATE = 1
DEFAULT_CHARSET = 'UTF-8'
add_language('de', 'Deutsch', 'utf-8')

Changes in /etc/profile.d/mailman.sh

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /etc/profile.d/mailman.sh

Changed on 09.06.10
Issued by olli
Beginning line 1

Add the bin-path of the mailman-progs to the default path-variable

PATH="$PATH:/usr/lib/mailman/bin"

Changes in /usr/local/sbin/maillists-2.sh

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /usr/local/sbin/maillists-2.sh

Changed on 17.11.2014
Issued by olli
Beginning line 2

Script for syncing LDAP-Groups with Mailinglists


#!/bin/bash

rm -f /tmp/liste-*
getent group | grep "^maillist-" >/tmp/maillists
cat /tmp/maillists | while read line
do
 list=`echo $line | cut -d: -f1 | perl -pe 's/^maillist-//'`
 # Erstelle liste falls nicht vorhanden...
 if list_lists | grep -iq $list
 then
  echo "Liste $list existiert" >/dev/null
 else
  echo "Erstelle Liste $list"
  newlist -u mailman.example.com -l de -q $list mail@example.com `gtc-crypt -a mailman -p`
  config_list -i /etc/mailman/defaultlistconfig $list
 fi
 # Pflege User
 list_members $list >/tmp/maillistmembers
 for i in `cat /tmp/maillistmembers`
 do
  echo whitelist_from mail@example.com
 done
 cat /etc/spamassassin/maillist-whitelist | sort -u >/tmp/maillist-whitelist
 cat /tmp/maillist-whitelist >/etc/spamassassin/maillist-whitelist
 # User aufnehmen
 for user in `echo $line | cut -d: -f4 | perl -pe 's/\,/ /g' ; cat /root/maillist-nongabosh-$list 2>/dev/null`
 do
  if grep -qi "^$user" /tmp/maillistmembers
  then
   echo "User $user ist in der Liste $list" >/dev/null
  else
   echo "User $user wird in die Liste $list aufgenommen"
   echo $user | grep -q '@' || user="$mail@example.com"
   echo "$user" >/tmp/maillistnew
   add_members -r /tmp/maillistnew -a y $list
  fi
 done
 # User rauswerfen
 for user in `cat /tmp/maillistmembers | perl -pe 's/\@example.com$//'`
 do
  if echo $line | cut -d: -f4 | grep -qi "$user"
  then
   echo "User $user ist in der Liste $list" >/dev/null
  elif cat /root/maillist-nongabosh-$list 2>/dev/null | grep -qi "$user"
  then
   echo "User $user ist in der Liste $list" >/dev/null
  else
   echo $user | grep -q '@' || user="$mail@example.com"
   echo "User $user wird aus der Liste $list gelöscht"
   remove_members -n $list $user
  fi
 done
 # Alle Nicht example.com-Mailadressen erlauben an Mailingliste zu senden (nicht lesen)
 
 echo -n "accept_these_nonmembers = [ 'mail@example.com', " >/tmp/maillistsendok
 for mail in `cat /etc/spamassassin/* 2>/dev/null | egrep "^whitelist_from mail@example.com
 do 
  echo -n " '$mail'," >>/tmp/maillistsendok
 done
 echo -n ' ]' >>/tmp/maillistsendok
 config_list -i /tmp/maillistsendok $list
done

# Aufräumen
#rm -f /tmp/maillists /tmp/maillistmembers /tmp/maillistnew


Changes in /usr/local/sbin/maillists.sh

File permissions:
Owner: mailman
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /usr/local/sbin/maillists.sh

Changed on 17.11.2014
Issued by olli
Beginning line 2

Script for syncing LDAP-Groups with Mailinglists


#!/bin/bash

if ! whoami | grep -q mailman
then
 echo "Dieses Skript muss als mailman-User ausgeführt werden"
 exit 1
fi

rm -f /tmp/liste-*
getent group | grep "^maillist-" | perl -pe 's/$/,root,admin/' >/tmp/maillists
cat /tmp/maillists | while read line
do
 list=`echo $line | cut -d: -f1 | perl -pe 's/^maillist-//'`
 # Erstelle liste falls nicht vorhanden...
 if mailman lists -q  | grep -iq $list
 then
  echo "Liste $list existiert" >/dev/null
 else
  echo "Erstelle Liste $list"
  mailman create --language de -o mail@example.com ${list}@example.com 
  #config_list -i /etc/mailman/defaultlistconfig $list
 fi
 # Pflege User
 mailman members -e ${list}@example.com | grep '@' >/tmp/maillistmembers
 for i in `cat /tmp/maillistmembers`
 do
  echo whitelist_from mail@example.com
 done
 cat /etc/spamassassin/maillist-whitelist | sort -u >/tmp/maillist-whitelist
 cat /tmp/maillist-whitelist >/etc/spamassassin/maillist-whitelist
 # User aufnehmen
 for user in `echo $line | cut -d: -f4 | perl -pe 's/\,/ /g' ; cat ~/maillist-nongabosh-$list 2>/dev/null`
 do
  if grep -qi "^$user" /tmp/maillistmembers
  then
   echo "User $user ist in der Liste $list" >/dev/null
  else
   echo "User $user wird in die Liste $list aufgenommen"
   echo $user | grep -q '@' || user="$mail@example.com"
   echo "$user" >/tmp/maillistnew
   mailman addmembers -W /tmp/maillistnew ${list}@example.com
  fi
 done
 # User rauswerfen
 for user in `cat /tmp/maillistmembers | perl -pe 's/\@example.com$//'`
 do
  if echo $line | cut -d: -f4 | egrep -qi "$user"
  then
   echo "User $user ist in der Liste $list" >/dev/null
  elif cat ~/maillist-nongabosh-$list 2>/dev/null | egrep -qi "$user"
  then
   echo "User $user ist in der Liste $list" >/dev/null
  else
   echo $user | grep -q '@' || user="$mail@example.com"
   echo "User $user wird aus der Liste $list gelöscht"
   mailman delmembers -G -m $user -l ${list}@example.com
  fi
 done
 # Alle Nicht example.com-Mailadressen erlauben an Mailingliste zu senden (nicht lesen)
 
# echo -n "accept_these_nonmembers = [ 'mail@example.com', " >/tmp/maillistsendok
# for mail in `cat /etc/spamassassin/* 2>/dev/null | egrep "^whitelist_from mail@example.com
# do 
#  echo -n " '$mail'," >>/tmp/maillistsendok
# done
# echo -n ' ]' >>/tmp/maillistsendok
# config_list -i /tmp/maillistsendok $list
done

# Aufräumen
#rm -f /tmp/maillists /tmp/maillistmembers /tmp/maillistnew


Setting up services

For starting the new service after system reboot you should add it to a runlevel with the following command(s):

rc-update add mailman 

Please send a feedback to: doc<at>gabosh.net

Howto listing
File Index

Here you can find the official Gentoo Linux Forums where you can find a lot of answers.

Here a link to the official Gentoo Linux Homepage.

Edit Howto

About / Impressum

Click here for About / Impressum

Wishlist

If you want to support my work you can find my Amazon whishlist here