20 Jan
                
                    2010
                
            
            
                20 Jan
                
                '10
                
            
            
            
        
    
                12:18 a.m.
            
        - Michael [2010-01-20 10:02]: [...]
 
As long as the query can be different for LDA vs. POP3/Imap is good for me thanks.
Having said that if there is no reason not to make it a configurable option for LDA vs. POP3 vs. Imap may as well go the full way?
Just of curiosity, have you tried replacing %n with %u after WHERE as I suggested?
<snip> A suggestion is that you replace the first line after WHERE with
 ((mailboxes.username = '%u' AND accounts.active='1') ||
That is, you replace %n with %u. </snip>
Kirill