From c214a3858751b5c4ac1789d62bdb388669c6d48b Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 27 Mar 2009 15:03:51 +0100 Subject: [PATCH] Bugfix: postfix is looking for a relative path when looking for a mailbox storage path. Absolute path was used in the Mailbox model. Added documentation. --- INSTALL | 55 ++++++++++++++++++++++++++++++++++++++----------- admin/models.py | 13 +++++++----- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/INSTALL b/INSTALL index e1f0d1fa9..269567615 100644 --- a/INSTALL +++ b/INSTALL @@ -68,35 +68,36 @@ Postfix versions >= 2.2):: user = password = dbname = + hosts = 127.0.0.1 query = SELECT name FROM admin_domain WHERE name='%s' AND enabled='1' # /etc/postfix/sql-mailboxes.cf user = password = dbname = - query = SELECT path FROM admin_mailbox WHERE full_address = '%s' AND enabled = '1' + hosts = 127.0.0.1 + query = SELECT path FROM admin_mailbox WHERE full_address = '%s' # /etc/postfix/sql-aliases.cf user = password = dbname = - query = SELECT t2.full_address FROM admin_alias AS t1, admin_mailbox AS t2 - WHERE t1.full_address='%s' AND t1.mbox=t2.id - AND t1.enabled='1' + hosts = 127.0.0.1 + query = SELECT t2.full_address FROM admin_alias AS t1, admin_mailbox AS t2 WHERE t1.full_address='%s' AND t1.mbox_id=t2.id AND t1.enabled='1' Then, use the following configuration in your /etc/postfix/main.cf file (this is one possible configuration):: # Stuff before mailbox_transport = virtual - home_mailbox = Maildir/ + home_mailbox = .maildir/ maildrop_destination_recipient_limit = 1 - virtual_minimum_uid = 500 - virtual_gid_maps = static:500 - virtual_uid_maps = static:500 + virtual_minimum_uid = + virtual_gid_maps = static: + virtual_uid_maps = static: virtual_mailbox_base = /var/vmail - relay_domains = mysql:/etc/postfix/sql-domains.cf + relay_domains = virtual_mailbox_domains = mysql:/etc/postfix/sql-domains.cf virtual_mailbox_maps = mysql:/etc/postfix/sql-mailboxes.cf virtual_alias_maps = mysql:/etc/postfix/sql-aliases.cf @@ -120,10 +121,15 @@ following inside:: args = /etc/dovecot/dovecot-sql.conf } + userdb sql { + # Path for SQL configuration file + args = /etc/dovecot/dovecot-sql.conf + } + # ... stuff after } -Be sure to activate only one backend inside your configuration +Be sure to activate only one backend (per type) inside your configuration (comment other ones). Then, edit your /etc/dovecot/dovecot-sql.conf and modify following lines:: @@ -131,5 +137,30 @@ Then, edit your /etc/dovecot/dovecot-sql.conf and modify following lines:: driver = mysql connect = host= dbname= user= password= default_pass_scheme = PLAIN-MD5 - password_query = SELECT address as user, password FROM admin_mailbox WHERE full_address = '%u' - user_query = SELECT path as home, uid, gid FROM admin_mailbox WHERE full_address = '%u' + password_query = SELECT full_address AS user, password FROM admin_mailbox WHERE full_address = '%u' + user_query = SELECT path AS home, uid, gid FROM admin_mailbox WHERE full_address = '%u' + +Tips to server Mailng behind Apache2 +------------------------------------ + +First, be sure to have apache2 and mod_python installed on your +server. + +Create a new virtualhost in your Apache configuration and put the +following inside:: + + + + SetHandler mod_python + PythonHandler django.core.handlers.modpython + PythonPath "[''] + sys.path" + SetEnv DJANGO_SETTINGS_MODULE mailng.settings + + Alias "/static" "/static" + + SetHandler None + + + +This is one possible configuration. Note that you will certainly need more +configuration in order to launch Apache. \ No newline at end of file diff --git a/admin/models.py b/admin/models.py index a4e6988dd..e02ea1d8f 100644 --- a/admin/models.py +++ b/admin/models.py @@ -11,7 +11,8 @@ class Domain(models.Model): def create_dir(self): code, output = exec_pipe("sudo -u %s mkdir %s/%s" \ - % (settings.VIRTUAL_UID, settings.STORAGE_PATH, + % (settings.VIRTUAL_UID, + settings.STORAGE_PATH, self.name)) if code: os.system("echo '%s' >> /tmp/vmail.log" % output) @@ -30,7 +31,8 @@ class Domain(models.Model): def delete_dir(self): code, output = exec_pipe("sudo -u %s rm -r %s/%s" \ - % (settings.VIRTUAL_UID, settings.STORAGE_PATH, + % (settings.VIRTUAL_UID, + settings.STORAGE_PATH, self.name)) if code: return False @@ -58,7 +60,7 @@ class Mailbox(models.Model): % (settings.VIRTUAL_UID, path)) if code: return False - self.path = "%s/.maildir/" % path + self.path = "%s/%s/.maildir/" % (domain.name, self.address) return True def rename_dir(self, domain, newaddress): @@ -69,12 +71,13 @@ class Mailbox(models.Model): if code: os.system("echo '%s' >> /tmp/vmail.log" % output) return False - self.path = "%s/%s/.maildir/" % (path, newaddress) + self.path = "%s/%s/.maildir/" % (domain, newaddress) return True def delete_dir(self): code, output = exec_pipe("sudo -u %s rm -r %s/%s/%s" \ - % (settings.VIRTUAL_UID, settings.STORAGE_PATH, + % (settings.VIRTUAL_UID, + settings.STORAGE_PATH, self.domain.name, self.name)) if code: return False