Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

    IF(isimap=1 OR '$(service)'='webmail','disableimap=0,','disableimap=1,'),\
  FROM mail_users WHERE username = '$(local_part)@$(domain)'

The service variable comes from the daemon config file. Is there something similar in dovecot?

share|improve this question

You can use the %s variable to check what service is being requested. See .

Something like this could work for you as the SQL query:

  '%u' AS username, '%d' AS domain,
  password, uid, gid, homedir AS home
FROM mail_users
  CONCAT('%u', '@', '%d') = username'' AND
  (isimap=1 OR '%s' <> 'imap')


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.