I'm attaching a current version of courier-to-mailman.py for possible inclusion
in mailman's contrib directory in the source tree. I recently updated it a tad
to properly handle confirmation address cookies in newer versions of mailman,
and the script is in use, quite happily, on a production system.
This script is based on Bruce Perens' qmail-to-mailman.py, but it's specific to
the Courier MTA <http://www.courier-mta.org/> and the code and the install
instructions (in the file comments) have been modified accordingly. Additional
changes to the configure script would be necessary to do the proper token
replacements at build time.
It ought to be noted that qmail-to-mailman.py probably won't work as-is at this
point, since it allows neither for the current format of VERP addresses in
bounce messages nor for the use of confirmation addresses with cookies. The
flip side is that although qmail has been largely unsupported for some time,
the script provides a useful example of how to do this stuff creatively.
--
Lindsay Haisley | "Fighting against human | PGP public key
FMP Computer Services | creativity is like | available at
512-259-1190 | trying to eradicate | <http://pubkeys.fmp.com>
http://www.fmp.com | dandelions" |
| (Pamela Jones) |
#! @PYTHON@
# Configuration variables - Change these for your site if necessary.
#
MailmanHome = "@prefix@"; # Mailman home directory.
MailmanVar = "@VAR_PREFIX@"; # Mailman directory for mutable data.
MailmanOwner = "[EMAIL PROTECTED]"; # Postmaster and abuse mail recepient.
#
# End of configuration variables.
# courier-to-mailman.py
#
# Interface mailman to a Courier virtual domain. Does not require the creation
# of _any_ list-specific aliases to connect lists to your mail system.
#
# Adapted March 29, 2004 by Lindsay Haisley, [EMAIL PROTECTED] from
# qmail-to-mailman.py by Bruce Perens, [EMAIL PROTECTED], March 1999.
#
# Updated Nov 3, 2006 by Lindsay Haisley to handle confirmation
# address cookies in newer versions of mailman.
#
# This is free software under the GNU General Public License.
#
# This script is meant to be called from
# <domain_home>/alias/.courier-default. It catches all mail to any address
# at a virtual domain not otherwise handled by an explicit account or a
# .courier file. It looks at the recepient for each mail message not
# otherwise handled and decides if the mail is addressed to a valid list or
# not, and bounces the message with a helpful suggestion if it's not
# addressed to a list. It decides if it is a posting, a list command, or
# mail to the list administrator by checking for the various address tags as
# defined in manual Mailman list creation output (~mailman/bin/newlist). It
# will recognize a list as soon as the list is created. Above and beyond
# setting up a proper locally-hosted domain in Courier (the use of webadmin
# is highly recommended!), no other configuration should be required. This
# program recognizes mail to postmaster, mailman-owner, abuse,
# mailer-daemon, root, and owner, and routes those mails to MailmanOwner as
# defined in the configuration variables, above.
#
# INSTALLATION:
#
# Install this file as ~mailman/bin/courier-to-mailman.py
#
# To configure a virtual domain to connect to mailman, create these files:
#
# <domain_home>/alias/.courier-default
# ... containing ...
# |/usr/bin/preline @prefix@/bin/courier-to-mailman.py
#
# Paths must, of course, be set correctly for the Courier and Mailman
# installations on your system.
#
# Note: "preline" is a Courier program which ensures a Unix "From " header
# is on the message. Archiving will break without this.
import sys, os, re, string
def main():
os.nice(5) # Handle mailing lists at non-interactive priority.
os.chdir(MailmanVar + "/lists")
try:
local = string.lower(os.environ["LOCAL"])
except:
# This might happen if we're not using qmail.
sys.stderr.write("LOCAL not set in environment?\n")
sys.exit(112)
names = ("root", "postmaster", "mailer-daemon", "mailman-owner", "owner",
"abuse")
for i in names:
if i == local:
os.execv("/usr/bin/sendmail",
("/usr/bin/sendmail", MailmanOwner))
sys.exit(0)
type = "post"
listname = string.lower(local)
types = (("-admin$", "admin"),
("-bounces$", "bounces"),
("-bounces\+.*$", "bounces"), # for VERP
("-confirm$", "confirm"),
("-confirm\+.*$", "confirm"),
("-join$", "join"),
("-leave$", "leave"),
("-owner$", "owner"),
("-request$", "request"),
("-subscribe$", "subscribe"),
("-unsubscribe$", "unsubscribe"))
for i in types:
if re.search(i[0],local):
type = i[1]
listname = re.sub(i[0],"",local)
if os.path.exists(listname):
os.execv(MailmanHome + "/mail/mailman",
(MailmanHome + "/mail/mailman", type, listname))
else:
bounce()
sys.exit(111)
def bounce():
bounce_message = """\
TO ACCESS THE MAILING LIST SYSTEM: Start your web browser on
http://%s/
That web page will help you subscribe or unsubscribe, and will
give you directions on how to post to each mailing list.\n"""
sys.stderr.write(bounce_message % (os.environ["HOST"]))
sys.exit(100)
try:
sys.exit(main())
except SystemExit, argument:
sys.exit(argument)
except Exception, argument:
info = sys.exc_info()
trace = info[2]
sys.stderr.write("%s %s\n" % (sys.exc_type, argument))
sys.stderr.write("Line %d\n" % (trace.tb_lineno))
sys.exit(111) # Soft failure, try again later.
_______________________________________________
Mailman-Developers mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-developers
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives:
http://www.mail-archive.com/mailman-developers%40python.org/
Unsubscribe:
http://mail.python.org/mailman/options/mailman-developers/archive%40jab.org
Security Policy:
http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp