3
# Configuration variables - Change these for your site if necessary.
5
MailmanHome = "@prefix@"; # Mailman home directory.
6
MailmanVar = "@VAR_PREFIX@"; # Mailman directory for mutable data.
7
MailmanOwner = "postmaster@localhost"; # Postmaster and abuse mail recepient.
9
# End of configuration variables.
11
# courier-to-mailman.py
13
# Interface mailman to a Courier virtual domain. Does not require the creation
14
# of _any_ list-specific aliases to connect lists to your mail system.
16
# Adapted March 29, 2004 by Lindsay Haisley, fmouse@fmp.com from
17
# qmail-to-mailman.py by Bruce Perens, bruce@perens.com, March 1999.
19
# This is free software under the GNU General Public License.
21
# This script is meant to be called from
22
# <domain_home>/alias/.courier-default. It catches all mail to any address
23
# at a virtual domain not otherwise handled by an explicit account or a
24
# .courier file. It looks at the recepient for each mail message not
25
# otherwise handled and decides if the mail is addressed to a valid list or
26
# not, and bounces the message with a helpful suggestion if it's not
27
# addressed to a list. It decides if it is a posting, a list command, or
28
# mail to the list administrator by checking for the various address tags as
29
# defined in manual Mailman list creation output (~mailman/bin/newlist). It
30
# will recognize a list as soon as the list is created. Above and beyond
31
# setting up a proper locally-hosted domain in Courier (the use of webadmin
32
# is highly recommended!), no other configuration should be required. This
33
# program recognizes mail to postmaster, mailman-owner, abuse,
34
# mailer-daemon, root, and owner, and routes those mails to MailmanOwner as
35
# defined in the configuration variables, above.
39
# Install this file as @prefix@/bin/courier-to-mailman.py
41
# To configure a virtual domain to connect to mailman, create these files:
43
# <domain_home>/alias/.courier-listname
45
# |/usr/bin/preline @prefix@/bin/courier-to-mailman.py
47
# Symlink <domain_home>/alias/.courier-listname-default to this file
49
# "listname" is the name of your list.
51
# Paths must, of course, be set correctly for the Courier and Mailman
52
# installations on your system.
54
# Note: "preline" is a Courier program which ensures a Unix "From " header
55
# is on the message. Archiving will break without this.
57
import sys, os, re, string
60
os.nice(5) # Handle mailing lists at non-interactive priority.
62
os.chdir(MailmanVar + "/lists")
65
local = string.lower(os.environ["LOCAL"])
67
# This might happen if we're not using qmail.
68
sys.stderr.write("LOCAL not set in environment?\n")
71
names = ("root", "postmaster", "mailer-daemon", "mailman-owner", "owner",
75
os.execv("/usr/bin/sendmail",
76
("/usr/bin/sendmail", MailmanOwner))
80
listname = string.lower(local)
81
types = (("-admin$", "admin"),
82
("-bounces$", "bounces"),
83
("-bounces\+.*$", "bounces"), # for VERP
84
("-confirm$", "confirm"),
85
("-confirm\+.*$", "confirm"),
89
("-request$", "request"),
90
("-subscribe$", "subscribe"),
91
("-unsubscribe$", "unsubscribe"))
94
if re.search(i[0],local):
96
listname = re.sub(i[0],"",local)
98
if os.path.exists(listname):
99
os.execv(MailmanHome + "/mail/mailman",
100
(MailmanHome + "/mail/mailman", type, listname))
107
bounce_message = """\
108
TO ACCESS THE MAILING LIST SYSTEM: Start your web browser on
110
That web page will help you subscribe or unsubscribe, and will
111
give you directions on how to post to each mailing list.\n"""
112
sys.stderr.write(bounce_message % (os.environ["HOST"]))
117
except SystemExit, argument:
120
except Exception, argument:
121
info = sys.exc_info()
123
sys.stderr.write("%s %s\n" % (sys.exc_type, argument))
124
sys.stderr.write("LINE %d\n" % (trace.tb_lineno))
125
sys.exit(111) # Soft failure, try again later.