On 8/7/12 8:58 PM, email builder wrote:
>>> Probably the best lesson to learn from postfixadmin is: you can
>>> have
> 
>>> more than one lookup table in postfix per main.cf directive. 
>>> Postfixadmin uses 2 separate queries for "regular" aliases and 
>>> domain aliases.
>>> 
>>> from main.cf: virtual_alias_maps =
>>> /etc/postfix/mysql_virtual_alias_maps.cf 
>>> /etc/postfix/virtual_alias_domain_maps.cf
>>> 
>>> where each file contains a simple db query. Makes it much easier
>>> to write the correct query, on the expense of some more db load.
>> 
>> Thanks Tom for making it more clear.
>> 
>> However, if you split to two queries, you still need a complex
>> query for the mapped domain. In my example, still like:
>> 
>> query = select if ('%d' = 'example-2.com', IFNULL((select dest from
>> aliases where addr = '%u...@example.com'), (select addr from users 
>> where addr = '%u...@example.com')), NULL)
>> 
>> I've found that in conjunction with a 2nd query (the original
>> normal one), everything seems to work as expected (including
>> aliases with only local parts like "postmaster")
>> 
>> But I'm still unsure if this kind of query is correct, if I'm on
>> the right track. Can anyone tell me if there's a better way to do
>> it?
>> 
>> Where are all those examples that are supposedly posted on this
>> list previously?
> 
> Bump - surely there's someone out there who has done this and can
> tell me if the kind of query above is either misguided or
> approximately what is needed to achieve this feature.
> 
> ie, Do I really have to query the alias table AND the account table?
> 
> 
> People have said on this list that other examples have been posted,
> but I can't find them.  Can someone please help?
> 

You have been pointed to postfixadmin before, which has all of this
builtin. Did you check their documentation? Every existing db-based
postfix adminsitration suite should have an example for you.

My query for alias domains on postgres, using postfixadmin database model:

query = SELECT goto FROM postfix_alias AS alias, postfix_alias_domain AS
alias_domain WHERE alias_domain.alias_domain = '%d' AND alias.address =
'%u' || '@' || alias_domain.target_domain AND alias.active = '1' AND
alias_domain.active = '1'

Definitely less hurting the head than your query this early in the
morning, imho.

--
Tom

Reply via email to