new images
[exim-website.git] / config.samples / C041
1 Date: Mon, 19 Mar 2001 17:33:11 +0300
2 From: "Alexei V. Alexandrov" <ava@elcomsoft.com>
3
4   Attaced  you  will  find a plain text file where i explain how to
5   setup  mailman  to use virtual environment (single setup for many
6   domains). I think this will help exim users.
7
8   If you have any questions, don not hesitate to contact me.
9
10
11 Using Mailman in virtual environment.
12
13 Download mailman and install it in a directory you prefer. (Note: compile mailman
14 to use the GID that your virtual accounts use. mine is "virtual").
15 Let`s presume that all virtual servers have an account in group named "virtual".
16 Setup exim to use mailman in the following way:
17
18 MAILMAN_HOME  = /virtual/usr/mailman
19 MAILMAN_WRAP  = MAILMAN_HOME/mail/wrapper
20 MAILMAN_UID   = exim
21 MAILMAN_GID   = virtual
22
23 ######################################################################
24 #                      TRANSPORTS CONFIGURATION                      #
25 ######################################################################
26
27 mailman:
28         driver = pipe
29         command = MAILMAN_WRAP post ${lc:$local_part}
30         current_directory = MAILMAN_HOME
31         home_directory = MAILMAN_HOME
32         user = MAILMAN_UID
33         group = MAILMAN_GID
34
35 mailman_request:
36         driver = pipe
37         command = MAILMAN_WRAP mailcmd ${lc:$local_part}
38         current_directory = MAILMAN_HOME
39         home_directory = MAILMAN_HOME
40         user = MAILMAN_UID
41         group = MAILMAN_GID
42
43 mailman_admin:
44         driver = pipe
45         command = MAILMAN_WRAP mailowner ${lc:$local_part}
46         current_directory = MAILMAN_HOME
47         home_directory = MAILMAN_HOME
48         user = MAILMAN_UID
49         group = MAILMAN_GID
50
51 ######################################################################
52 #                      DIRECTORS CONFIGURATION                       #
53 #             Specifies how local addresses are handled              #
54 ######################################################################
55
56 # Note: these directors should go after forward file driver
57 #       and before smart user driver (if you use "catchall" for your
58 #       virtual domains)
59
60 virtual_list_owner:
61         driver = smartuser
62         require_files = MAILMAN_HOME/${lc:$domain}/lists/${lc:$local_part}/config.db
63         suffix = "-owner"
64         new_address = "${lc:$local_part}-admin@${domain}"
65
66 virtual_owner_list:
67         driver = smartuser
68         require_files = MAILMAN_HOME/${lc:$domain}/lists/${lc:$local_part}/config.db
69         prefix = "owner-"
70         new_address = "${lc:$local_part}-admin@${domain}"
71
72 virtual_list_admin:
73         driver = smartuser
74         suffix = -admin
75         require_files = MAILMAN_HOME/${lc:$domain}/lists/${lc:$local_part}/config.db
76         transport = mailman_admin
77
78 virtual_list_request:
79         driver = smartuser
80         suffix = -request
81         require_files = MAILMAN_HOME/${lc:$domain}/lists/${lc:$local_part}/config.db
82         transport = mailman_request
83
84 virtual_list:
85         driver = smartuser
86         require_files = MAILMAN_HOME/${lc:$domain}/lists/${lc:$local_part}/config.db
87         transport = mailman
88
89 # The trick is that we create in MAILMAN_HOME directories named like domains that we
90 # recieve mail for. The sufficient directory structure is the following:
91 # MAILMAN_HOME
92 # |__/data/
93 # |__/lists/
94 # |__/logs/
95 # |__/qfiles/
96 # |__/locks/
97
98 We have succesfully setup exim to use mailman listmanager. Next we will have to tweak
99 mailman to suite our virtual setup. What we do. Mailman has its default configuration
100 stored in MAILMAN_HOME/Mailman/Defaults.py this file is imported by mm_cfg.py and is
101 used by all other modules. We will twak it to use defaults.py for different domains.
102 Here is how i did it:
103
104 MAILMAN_HOME/Mailman/mm_cfg.py:
105
106 import os
107 import string
108
109 def loadDefaults ( name ):
110         definition = ""
111         module = '/vhost/usr/mailman/' + name + '/Defaults.py'
112         hFile = open ( module, "r" )
113         for line in hFile.readlines():
114                 definition = definition + line
115         definition = definition + "\n"
116         exec definition in globals()
117
118 if os.environ.get('HTTP_HOST') :
119         junk, domain = tuple(string.split(os.environ['HTTP_HOST'], '.', 1))
120         loadDefaults(domain)
121 elif os.environ.get('DOMAIN') :
122         loadDefaults(os.environ['DOMAIN'])
123 else:
124         loadDefaults('Mailman')
125
126 # from Defaults import *
127
128 The Defaults.py is stored in the directory: MAILMAN_HOME/domain.com/Defaults.py
129 and is not different from the original one. The lines you should modify are:
130
131 DEFAULT_HOST_NAME   = 'domain.com'
132 DEFAULT_URL         = 'http://mail.%s/' % DEFAULT_HOST_NAME
133
134 LIST_DATA_DIR   = os.path.join(VAR_PREFIX, DEFAULT_HOST_NAME + '/lists')
135 LOG_DIR         = os.path.join(VAR_PREFIX, DEFAULT_HOST_NAME + '/logs')
136 LOCK_DIR        = os.path.join(VAR_PREFIX, DEFAULT_HOST_NAME + '/locks')
137 DATA_DIR        = os.path.join(VAR_PREFIX, DEFAULT_HOST_NAME + '/data')
138 QUEUE_DIR       = os.path.join(VAR_PREFIX, DEFAULT_HOST_NAME + '/qfiles')
139
140 We use two environment variables on is HTTP_HOST (to be able to use mailman
141 managment interface for different domains). Other one is DOMAIN (this variable
142 is set by exim). Another thing is is to be able to run the man mailman script
143 called qrunner. As users have there accounts in the system, they are able to use cron.
144 Create a crontab file in the user`s directory with the following contents:
145
146 DOMAIN=domain.com
147
148 * * * * * /virtual/bin/python -S /virtual/usr/mailman/cron/qrunner
149
150 This will set the DOMAIN variable so the qrunner will use the right settings.
151
152 If you want to create a new list. first set the environment variable DOMAIN to the
153 desired domain and run the command MAILMAN_HOME/bin/newlist
154
155 About the managment interface everything is simple. Run the apache server and bind
156 it to a specific address (for ex.: 192.168.10.10). Create for each domain DNS record
157 listserv        IN      A       192.168.10.10
158 When the user will point his browser to http://listserv.domain.com/ he will see a list
159 of available mailing lists or he will get an error message indicating that the default settings
160 for this domain are not available.
161
162 That`s it. This setup works for me and it handles over 50 domains.