This howto describes howto replace the courier-pop/imap/authdaemon/maildrop with the according services... Please report any bugs/hints/whatever in the following board thread:\\ http://www.isp-control.net/forum/howto-replace-courier-with-dovecot-t-1421.html \\ Please change every "mypass" in the Files with a real password! ====== 1. Check if systems hostname resolvable ====== > hostname this must be resolvable ====== 2. Add sql user ====== > mysql -u root -p mysql mysql> GRANT SELECT ON ispcp.* to 'ispcp_dovecot'@'localhost' identified by 'mypass'; mysql> FLUSH PRIVILEGES; mysql> quit; ====== 3. Stop Courier services ====== > /etc/init.d/courier-pop stop > /etc/init.d/courier-imap stop > /etc/init.d/courier-authdaemon stop > /etc/init.d/saslauthd stop ====== 4. Install dovecot ====== > apt-get update > apt-get install dovecot-common dovecot-imapd dovecot-pop3d ====== 5. Configure dovecot ====== Replace the file /etc/dovecot/dovecot.conf with the following one (you should backup the original because there are a lot of comments in it explainig all the configuration parameters... > cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.org Then safe this content as your /etc/dovecot/dovecot.conf base_dir = /var/run/dovecot/ protocols = imap pop3 disable_plaintext_auth = no listen=* syslog_facility = mail login_greeting = Dovecot ready. mail_location = maildir:/var/mail/virtual/%d/%n mail_privileged_group = mail protocol imap { } namespace private { prefix = INBOX. inbox = yes } protocol pop3 { pop3_uidl_format = %u-%v } protocol lda { postmaster_address = postmaster@yourdomain.tld auth_socket_path = /var/run/dovecot/auth-master } auth default { mechanisms = plain login digest-md5 passdb sql { args = /etc/dovecot/dovecot-sql-domain.conf } userdb sql { args = /etc/dovecot/dovecot-sql-domain.conf } passdb sql { args = /etc/dovecot/dovecot-sql-aliasdomain.conf } userdb sql { args = /etc/dovecot/dovecot-sql-aliasdomain.conf } passdb sql { args = /etc/dovecot/dovecot-sql-subdomain.conf } userdb sql { args = /etc/dovecot/dovecot-sql-subdomain.conf } socket listen { client { path = /var/spool/postfix/private/auth mode = 0660 user = postfix group = postfix } master { path = /var/run/dovecot/auth-master mode = 0660 user = vmail group = mail } } user = vmail } plugin { } Create a new file **/etc/dovecot/dovecot-sql-domain.conf** with the following content: \\ (In the sql for user_query there are uids and gids 'hardcoded'. The uid must be the uid of vmail user and gid the gid of the mail group. Maybe you have to change the defaults (1001/8)) driver = mysql connect = host=localhost dbname=ispcp user=ispcp_dovecot password=mypass password_query = SELECT md5(mail_pass) AS password FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and domain.domain_name='%d' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward'); user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '1001' as uid, '8' as gid FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and domain.domain_name='%d' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward'); Create a new file **/etc/dovecot/dovecot-sql-subdomain.conf** with the following content:\\ (In the sql for user_query there are uids and gids 'hardcoded'. The uid must be the uid of vmail user and gid the gid of the mail group. Maybe you have to change the defaults (1001/8)) driver = mysql connect = host=localhost dbname=ispcp user=ispcp_dovecot password=mypass password_query = SELECT md5(mail_pass) as password FROM (mail_users INNER JOIN subdomain ON mail_users.sub_id = subdomain.subdomain_id) INNER JOIN domain ON mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and concat(subdomain.subdomain_name,".",domain.domain_name)='%d'; user_query = SELECT concat('/var/mail/virtual/', subdomain.subdomain_name, ".", domain.domain_name, '/',mail_acc) as home, '1001' as uid, '8' as gid FROM (mail_users INNER JOIN subdomain ON mail_users.sub_id = subdomain.subdomain_id) INNER JOIN domain ON mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and concat(subdomain.subdomain_name,".",domain.domain_name)='%d'; Create a new file **/etc/dovecot/dovecot-sql-aliasdomain.conf** with the following content:\\ (In the sql for user_query there are uids and gids 'hardcoded'. The uid must be the uid of vmail user and gid the gid of the mail group. Maybe you have to change the defaults (1001/8)) driver = mysql connect = host=localhost dbname=ispcp user=ispcp_dovecot password=mypass password_query = SELECT md5(mail_pass) as password FROM (mail_users INNER JOIN domain_aliasses ON mail_users.sub_id = domain_aliasses.alias_id) INNER JOIN domain ON mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and domain_aliasses.alias_name ='%d'; user_query = SELECT concat('/var/mail/virtual/', domain_aliasses.alias_name, '/',mail_acc) as home, '1001' as uid, '8' as gid FROM (mail_users INNER JOIN domain_aliasses ON mail_users.sub_id = domain_aliasses.alias_id) INNER JOIN domain ON mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and domain_aliasses.alias_name ='%d'; Set correct permissions on dovecot.conf (deliver access this file too) > chmod 0644 /etc/dovecot/dovecot.conf ====== 6. Configure postfix ====== Change parameters in /etc/postfix/main.cf: smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes #smtpd_sasl2_auth_enable = yes smtpd_sasl_security_options = noanonymous #smtpd_sasl_local_domain = broken_sasl_auth_clients = yes virtual_transport = dovecot dovecot_destination_recipient_limit = 1 Add the following line to /etc/postfix/master.cf: dovecot unix - n n - - pipe flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -d ${recipient} ====== 7. Migrating existing Maildirs ====== If you are using existing maildirs which were accessed by courier you have to migrate the maildirs... this can be done with the courier-dovecot-migrate.pl script from http://wiki.dovecot.org/Migration/Courier ====== 8. Start Services ====== > /etc/init.d/dovecot start > /etc/init.d/postfix restart Next two steps only if you like to enable ssl ====== 9. Alter config file to enable ssl ====== Change/add the following lines to /etc/dovecot/dovecot.conf: protocols = imap pop3 imaps pop3s ssl_disable = no ====== 10. Generate some ssl certificates ====== > openssl req -new -x509 -days 365 -nodes -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem The script will ask you a few questions, here an example:\\ Country Name (2 letter code) [AU]: ''CH''\\ State or Province Name (full name) [Some-State]: ''Zurich''\\ Locality Name (eg, city) []: ''Esslingen''\\ Organization Name (eg, company) [Internet Widgits Pty Ltd]: ''My Hosting Company''\\ Organizational Unit Name (eg, section) []: ''Dovecot Secure Mailservice''\\ Common Name (eg, YOUR name) []: ''mail.domain.tld'' -> this should be equal to the servername you use for connect to the server...\\ Email Address []: ''hostmaster@domain.tld''\\ ====== 11. Test the whole thing... ====== ====== 12. Remove startup links ====== > update-rc.d -f courier-imap remove > update-rc.d -f courier-pop remove > update-rc.d -f courier-authdaemon remove > update-rc.d -f saslauthd remove ====== 13. Remove courier packages... ====== > apt-get remove courier-base courier-authdaemon courier-maildrop ====== 14. That's it ====== ====== 15. Quota (it's a bonus) ====== Ispcp is already assigning 10MB quota to each mail created, but it isn't applied by default, to enforce the quota usage, you can do the following steps: NOTE: The quota is stored in bytes in the table "mail_users" on a field named "quota" ====== 16. Changes in dovecot.conf ====== You have to add the following lines in the file (no need to remove anything) protocol imap { mail_plugins = quota imap_quota } protocol pop3 { mail_plugins = quota } protocol lda { mail_plugins = quota } ====== 17. Changes in dovecot-sql-domain.conf ====== Change the user query from: user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '1001' as uid, '8' as gid FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and domain.domain_name='%d' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward'); into: user_query = SELECT concat('/var/mail/virtual/', domain.domain_name, '/',mail_acc) as home, '1001' as uid, '8' as gid, concat('maildir:storage=', floor(quota/1024)) AS quota FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE mail_acc='%n' and (mail_type='normal_mail' OR mail_type='normal_mail,normal_forward'); ====== 18. You are done ======