Greetings all,

I have recently set up Mailman (www.list.org) on my mail server.  For
anyone who is doing similarly on a dedicated domain (lists.domain.com),
here's a perl script which you might find useful for integrating it with
courier that completely eliminates the need to create/remove any aliases
whenever you add/remove a list.

-ben



#!/usr/bin/perl

# courier-to-mailman.pl by Ben Kennedy [EMAIL PROTECTED] 30 July 2003.
#
# This is a simple script designed to facilitate dynamic aliasing for
# a dedicated mailing list domain serving any number of Mailman lists.
#
# Usage:
#
# First, configure a standard courier virtual domain alias for list
domain, e.g.
#               @lists.zygoat.ca: zygoat-lists
# The above will redeliver [EMAIL PROTECTED] as [EMAIL PROTECTED]
#
# Then, configure a corresponding .courier-default file piping to this script
# as a dynamic delivery instruction (double-pipe syntax).
# e.g. for the above example, in ~zygoat/.courier-lists-default:
#               ||path/to/courier-to-mailman.pl
#

# Path to local mailman installation:
$MAILMAN = '/usr/local/mailman';
# Path to mailman var data dirs:
$MAILMANVAR = '/var/mailman';

# Extract the appropriate mail delivery address from the environment.
# Assume the user sends a message to [EMAIL PROTECTED]
# If the message was delivered as [EMAIL PROTECTED],
# then we expect to see the following in the environment:
# USER = zygoat
# EXT = lists-doggiebox-subscribe
# EXT2 = doggiebox-subscribe
# EXT3 = subscribe
# and so on.
# Depending how aliases are configured and expanded locally, we must select
# the proper environment variable to get the string which corresponds to the
# original request address of the incoming message (doggiebox-subscribe).
$deliver = $ENV{'EXT2'};

# Here are the known/expected verbs (reserved words in end of list names):
$VERBS = ',post,admin,bounces,confirm
,join,leave,owner,request,subscribe,unsubscribe,';

# Ensure we snagged something suitable from the environment
if ($deliver eq '')
        {
        print <<EOT;
# $0 - error
# No suitable delivery was found in the environment.
# This is probably due to a configuration error.  See source for details.
EOT
        exit 64;
        }

# split the extension into two parts (e.g. for food-sack-bar):
$deliver =~ m/(.*?)-*(\w+)$/;
$a = $1 || 'unknown';   # will contain the first n-1 sections (food-sack)
$b = $2 || 'request';   # will contain the last section (bar)
if ($a eq '')
        {
        # there was only one component to begin with, therefore must be list name
        $listname = $a;
        $verb = 'post';
        }
elsif ($VERBS =~ m/,$b,/)
        {
        # second component was a verb, so first part is the list name
        $listname = $a;
        $verb = $b;
        }
else {
        # the whole shebang must be just the list name
        $listname = $deliver;
        $verb = 'post';
        }

# Try to determine whether the requested list actually exists.
# If it doesn't, generate a non-zero code since otherwise the message
# will just get stuck in queue and user will never hear back.
if (! -d "$MAILMANVAR/lists/$listname")
        {
        print <<EOT;
|perl -e 'print "There is no list by the name of \\"$listname\\".\\n";
exit 64;'
# It appears that list $listname does not exist.
EOT
        }
else {
        print <<EOT;
|$MAILMAN/mail/mailman $verb $listname
# Delivery instruction generated by $0.
EOT
        }

exit;





-- 
Ben Kennedy, chief magician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to