0

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?

1

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:

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

-Phil

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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