diff options
Diffstat (limited to 'fooconf-postfix-alias-map')
-rwxr-xr-x | fooconf-postfix-alias-map | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fooconf-postfix-alias-map b/fooconf-postfix-alias-map new file mode 100755 index 0000000..53fc10f --- /dev/null +++ b/fooconf-postfix-alias-map @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# Hey Emacs, this is -*-python-*- code! + +from fooconflib import * + +def generatePostfixAliasMapFragment(ctx = FooConfContext()): + cursor = ctx.db.cursor() + cursor.execute("SELECT DISTINCT local, domain, recipient " + + "FROM mail_alias, domain, account " + + "WHERE mail_alias.domain = domain.name " + + "AND domain.owner = account.id " + + "AND account.enabled = \"t\" " + + "AND type=\"forward\"") + + while 1: + row = cursor.fetchone() + if row is None: break + + print "%s@%s %s" % (row["local"], row["domain"], row["recipient"]) + +if __name__ == "__main__": + generatePostfixAliasMapFragment() |