View Single Post
  #2  
Old 12th October 2012, 17:30
ITFixt ITFixt is offline
Junior Member
 
Join Date: Aug 2012
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

I solved the problem like this:

In dovecot.conf, change
Code:
passdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}

userdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
to

Code:
passdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
userdb {
  driver = prefetch
}
#Following userdb only used for delivery, so lookup on email
userdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
And in dovecot-sql.conf, I used these two queries:

Code:
password_query = SELECT password, /
maildir AS userdb_home, /
uid AS userdb_uid, /
gid as userdb_gid /
FROM mail_user /
WHERE login = '%u' AND disable%Ls = 'n'

user_query = SELECT email as user, /
maildir as home, /
CONCAT('maildir:', maildir, '/Maildir') as mail, /
uid, gid, /
CONCAT('*:storage=', quota, 'B') AS quota_rule /
FROM mail_user /
WHERE email = '%u' AND disable%Ls = 'n'
This is more efficient than the original as only one query is executed to do user/PW lookup for mail client logon. As I've got ISPConfig set to use fixed UID & GID, it may well be possible to optimise this so that only the maildir & quota needs to be fetched from the DB, the rest of the fields being static.

As before, I'd appreciate comments. Although this now works, I still have the niggling feeling it should have been fixed some other way :}
Reply With Quote