Due to recurring performance and service issues, I recently migrated the IMAP service of a mail server from Courier-IMAP to Dovecot. The latter is known to be more robust and actively maintained. In this article, I will provide the notes that helped me accomplish this migration. They are specific to my architecture (Courier-IMAP + Courier-SMTP with authuserdb authentication), but I hope they can help others as well. Of course, taking a backup is highly recommended before making any modifications. Good reading!
root@host:~# apt update && apt install dovecot-imapd
Dovecot provides the courier-dovecot-migrate.pl script, which allows migrating from Courier-IMAP while preserving IMAP UIDs by converting the courierimapuiddb file to a dovecot-uidlist file. Source: https://wiki.dovecot.org/Migration/Courier.
root@host:~# wget https://raw.githubusercontent.com/dovecot/tools/main/courier-dovecot-migrate.pl
root@host:~# chmod +x courier-dovecot-migrate.pl
root@host:~# ./courier-dovecot-migrate.pl --to-dovecot --recursive --convert /data/vmail/std.rocks/
root@host:~# doveadm pw -s ssha512 -p <PASSWORD>
root@host:~# doveadm pw -s ssha512 -p std.rocks
{SSHA512}8lhtRxyXWP5azW1OjllkVUSuMPVABNtTR/MxMVTIEYXLXjoOMwCe/7Bpr1iqPi/nKutRbPxvBddG1pk2BVpgorhZPjI=
john@std.rocks:{SSHA512}8lhtRxyXWP5azW1OjllkVUSuMPVABNtTR/MxMVTIEYXLXjoOMwCe/7Bpr1iqPi/nKutRbPxvBddG1pk2BVpgorhZPjI=::::::
passdb {
#authentication method
driver = passwd-file
#specifies the format of the username in the password file.
args = username_format=%u /etc/dovecot/passwd
}
userdb {
driver = static
#specifies the home directory path for the mailbox, where %d represents the domain and %n represents the username.
args = uid=vmail gid=vmail home=/data/vmail/%d/%n
}
ssl = yes
#courier certificates:
#ssl_cert = <etc/courier/imapd.pem
#Note : split imapd.pem from -----BEGIN PRIVATE KEY----- to the end to create server.key
#ssl_key = <etc/courier/server.key
#Let's encrypt certificates:
ssl_cert = <etc/courier/fullchain.pem
ssl_key = <etc/courier/privkey.pem
mail_location = maildir:/data/vmail/%d/%n/Maildir
namespace {
prefix = INBOX.
separator = .
inbox = yes
}
auth_mechanisms = plain
!include auth-passwdfile.conf.ext
root@host:~# systemctl restart dovecot.service
After the installation and migration, I had to make some modifications, which I will detail here.
root@host:~# mv /etc/dovecot/conf.d/{15-mailboxes.conf,15-mailboxes.conf.disabled}
root@host:~# systemctl restart dovecot.service
Complete error: imap-login: Maximum number of connections from user+IP exceeded (mail_max_userip_connections=10): user=<john@std.rocks> :
mail_max_userip_connections = 30
root@host:~# systemctl restart dovecot.service
Complete error: master: Warning: service(imap-login): process_limit (100) reached, client connections are being dropped
default_process_limit = 200
root@host:~# systemctl restart dovecot.service
Complete error: Warning: Inotify instance limit for user 7200 (UID vmail) exceeded, disabling. Increase /proc/sys/fs/inotify/max_user_instances
fs.inotify.max_user_instances = 65535
fs.inotify.max_user_watches = 65535
root@host:~# sysctl -p /etc/sysctl.conf
root@host:~# systemctl restart dovecot.service
Complete error: imap(john@std.rocks)<1123794><2epGbh79Cui4hVBj> Fatal: master: service(imap): child 1313798 returned error 83 (Out of mem ory (service imap { vsz_limit=256 MB }, you may need to increase it) - set CORE_OUTOFMEM=1 environment to get core dump)
default_vsz_limit = 512M
root@host:~# systemctl restart dovecot.service
Contact :