Managing an email server is not an easy task. However, there are tools like Dovecot that allow us to configure it quickly so that at least, we have a lot of the way already done. This is what today’s post is about, learning how to install Dovecot on Debian 10.
Dovecot is an Open source IMAP and POP3 server for GNU/Linux / UNIX-like systems, written primarily with security in mind. However, it is also focused on being fast and easy to install and use.
Dovecot is among the best performing IMAP servers while still supporting the standard mbox and Maildir formats. Therefore, it is a very efficient solution in almost any environment. It is completely free but also has a commercial version.
Another important aspect is that Dovecot’s user authentication is extremely flexible and feature-rich, supporting many different authentication databases and mechanisms.
Users will never feel alone because Dovecot tries to be admin-friendly. Common error messages are made as easily understandable as possible.
So, now we can get started.
Install Dovecot on Debian 10
Although Dovecot supports both IMAP and POP3, on Debian-based distributions, the packages are separated. So, to install them connect to your server and after upgrading it, run this command
sudo apt install dovecot-imapd dovecot-pop3d
These are the packages needed to have Dovecot but there are also other packages with other modules. You can search for them using APT.
sudo apt search dovecot-*
Then you can install the ones you need.
Now you need to configure dovecot.
Configuring Dovecot on Debian 10
Before using it, it is necessary to make some settings in various configuration files. The first and most important of all is /etc/dovecot/dovecot.conf
.
First, make a backup of it and then proceed to edit it.
sudo cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bak sudo nano /etc/dovecot/dovecot.conf
In this file, we will make two modifications. The first is to make sure that the protocols supported by Dovecot are enabled. To do this, it is necessary to uncomment the following line:
!include_try /usr/share/dovecot/protocols.d/*.protocol
Also, in this file, we can define the interface through which Dovecot will work. By default all IPs are enabled, both IPv4 and IPv6.
This can be configured in the line.
listen = *, ::
Save the changes and close the editor.
Next, you need to check how Dovecot works with authentication. To do this, edit the /etc/dovecot/conf.d/10-auth.conf
file.
sudo cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.bak
Now you can edit it
sudo nano /etc/dovecot/conf.d/10-auth.conf
In this file, you need to set these lines
disable_plaintext_auth = no auth_mechanisms = plain login
Save the changes and close the editor again.
In the file /etc/dovecot/conf.d/10-mail.conf
is where we will have to define the path where the user’s email will be saved.
sudo cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.bak sudo nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir
Again, save the changes and close the editor
Finally, it is necessary to define the group and the user that will have permission to use Dovecot.
sudo cp /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak sudo nano /etc/dovecot/conf.d/10-master.conf
And modify the unix_listener /var/spool/postfix/private/auth
section.
unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix }
Save the changes and close the editor.
It is vital to secure Dovecot with SSL. So, you have to add the path of your certificates to the /etc/dovecot/conf.d/10-ssl.conf
file.
sudo cp /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.bak sudo nano /etc/dovecot/conf.d/10-ssl.conf
And you add it like this:
ssl = yes ssl_cert = [Certificates_path]
Save the changes and close the editor. Now we are ready.
What remains is to enable the Dovecot service and check the status.
sudo systemctl enable dovecot.service sudo systemctl status dovecot.service
Remember that for all this to work you need to open ports 143
, 993
, 110
, and 995
which correspond to IMAP, IMAPS, POP3, and POP3S.
Conclusion
Dovecot allows us to quickly have an IMAP and POP3 server that we can take advantage of for our email server.