From 1e9a8607b0ae8933ab01fd4ef37afb7a4aede1c6 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Thu, 18 Aug 2016 11:29:26 +0200 Subject: [PATCH] Fix prority between mailboxes and aliases, related to #38 --- postfix/conf/sqlite-virtual_alias_maps.cf | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/postfix/conf/sqlite-virtual_alias_maps.cf b/postfix/conf/sqlite-virtual_alias_maps.cf index 8accf7c5..8898ba73 100644 --- a/postfix/conf/sqlite-virtual_alias_maps.cf +++ b/postfix/conf/sqlite-virtual_alias_maps.cf @@ -1,18 +1,21 @@ dbpath = /data/freeposte.db query = - SELECT destination - FROM alias - WHERE - ( - alias.wildcard = 0 - AND - alias.email = '%s' - ) OR ( - alias.wildcard = 1 - AND - '%s' LIKE alias.email - ) - ORDER BY - alias.wildcard ASC, - length(alias.localpart) DESC - LIMIT 1 + SELECT destination + FROM + (SELECT destination, email, wildcard, localpart FROM alias + UNION + SELECT email AS destination, email, 0 as wildcard, localpart FROM user) + WHERE + ( + wildcard = 0 + AND + email = '%s' + ) OR ( + wildcard = 1 + AND + '%s' LIKE email + ) + ORDER BY + wildcard ASC, + length(localpart) DESC + LIMIT 1