We are running courier currently which enables us to set different SQL userdb queries for IMAP and POP3. We need this because we do not want to give all users IMAP access, a boolean column in the userdb allows IMAP access if set.
For performance and stability reasons we are currently migrating to dovecot. I found no way yet to either set different SQL queries based on POP3 or IMAP access - or to pass the access method as variable to the SQL query. Both ways would work.
Here's the relevant mysql config from courier:
MYSQL_SELECT_CLAUSE SELECT \
username,password_enc,password,uid,gid,homedir,maildir,'',CONCAT(\
IF(isimap=1 OR '$(service)'='webmail','disableimap=0,','disableimap=1,'),\
'disablepop3=0,disablewebmail=0'\
)\
FROM mail_users WHERE username = '$(local_part)@$(domain)'
The service variable comes from the daemon config file. Is there something similar in dovecot?
You can use the
%s
variable to check what service is being requested. See http://wiki2.dovecot.org/Variables .Something like this could work for you as the SQL query:
-Phil