[Mailman-Users] Automatic list alises for QMail

Sean Reifschneider jafo at tummy.com
Fri Sep 1 09:58:29 CEST 2000


I'd like comments on the following program.  The idea is that for QMail,
new lists will automaticly be detected and there will be no need to do
anything beyond "newlist".

Goodbye having to translate the sendmail alias entries into .qmail files.
Goodbye having to much with aliases ever again (as far as the list is
concerned).

Comments?

Sean
-- 
 I like to be different, so I built a lowercase a-frame house.
                 -- Sean Reifschneider, 2000
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python
-------------- next part --------------
#!/usr/bin/env python
#
#  mmvirtdlv -- MailMan Virtual Deliver
#
#  Sean Reifschneider, tummy.com, ltd.  <jafo-mmvirtdlv at tummy.com>
#  Copyright, tummy.com, ltd.  All Rights Reserved
#
#  The current version of this program is for QMail only.
#
#  The idea behind mmvirtdel is to allow automatic detection of new
#  mailman mailing lists.  It uses the "EXT" environment variables
#  as provided by QMail to determine the name of the list and the
#  function (request, owner, post).  If it can't determine the name
#  of the list or there is an invalid function specified, the message
#  is run through "forwardCmd" (default, forward to mailman-owner).
#
#  Setup:
#    Change "mailmanHome" to the home directory for mailman.
#      ("lists/<listname>" and "mail/wrapper" must exist under that directory)
#    Go to the mailman home directory and create ".qmail-default" containing:
#      |/path/to/mmvirtdel
#    Make sure that mail for "list" is now sent to "mailman-domain.com-list":
#      Add "lists.domain.com:mailman-lists.domain.com" to
#          "/var/qmail/control/virtualdomains"
#      Set up the appropriate alias files which forward the mail to
#        "mailman-domain.com-list" (though that's what we're trying to get
#        away from)

mailmanHome = '/home/mailman'
forwardCmd = '/var/qmail/forward mailman-owner'

destList = { 'owner' : 'mailowner %s', 'request' : 'mailcmd %s',
		'admin' : 'mailowner %s', 'list' : 'post %s' }

import os
import string


##############
def getExts():
	'''Return a list of the extensions.  Doing a string.join(list, '-') should
	result in the full extension of the local address.'''
	def addExt(l, e):
		s = os.environ.get(e, None)
		if s:	
			rstrip = string.join(l, '-')
			if len(s) >= len(rstrip) and s[-len(rstrip):] == rstrip:
				s = s[:-(len(rstrip) + 1)]
			l.insert(0, s)
	
	l = []
	addExt(l, 'EXT4')
	addExt(l, 'EXT3')
	addExt(l, 'EXT2')
	addExt(l, 'EXT')

	return(l)

################################
#  determine destination of list
extList = getExts()
destName = extList[1]
destCmd = None

#  <domain> <listname>
if len(extList) == 2: destType = destList.get('list', None)
#  <domain> <listname> <suffix>
if len(extList) == 3: destType = destList.get(extList[2], None)

#  if unknown destination, send to mailman-owner
if not destType:
	destCmd = forwardCmd

#  check for list existance
if not destCmd:
	destDir = os.path.join(mailmanHome, 'lists', destName)
	if not os.path.exists(destDir):
		destCmd = forwardCmd

#  otherwise, create "forward to list" command
if not destCmd:
	destCmd = os.path.join(mailmanHome, 'mail', 'wrapper')
	destCmd = destCmd + ' ' + (destType % destName)

ret = os.system(destCmd)
os.exit(ret)


More information about the Mailman-Users mailing list