summaryrefslogtreecommitdiffstats
path: root/fooconf-postfix-mailbox-map
diff options
context:
space:
mode:
Diffstat (limited to 'fooconf-postfix-mailbox-map')
-rwxr-xr-xfooconf-postfix-mailbox-map25
1 files changed, 25 insertions, 0 deletions
diff --git a/fooconf-postfix-mailbox-map b/fooconf-postfix-mailbox-map
new file mode 100755
index 0000000..03a8628
--- /dev/null
+++ b/fooconf-postfix-mailbox-map
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# Hey Emacs, this is -*-python-*- code!
+
+from fooconflib import *
+
+def generatePostfixMailboxMapFragment(ctx = FooConfContext()):
+ cursor = ctx.db.cursor()
+ cursor.execute("SELECT DISTINCT local, domain, recipient, account.name AS name " +
+ "FROM mail_alias, domain, account, mailbox " +
+ "WHERE mail_alias.domain = domain.name " +
+ "AND domain.owner = account.id " +
+ "AND mailbox.owner = account.id " +
+ "AND mailbox.enabled = \"t\" " +
+ "AND account.enabled = \"t\" " +
+ "AND type=\"mailbox\"")
+
+ while 1:
+ row = cursor.fetchone()
+ if row is None: break
+
+ print "%s@%s %s" % (row["local"], row["domain"], ctx.makeHomeDir(row["name"])+"/mail/"+row["recipient"])
+
+if __name__ == "__main__":
+ generatePostfixMailboxMapFragment()
+