Dovecot comes as the default mail storage option on many servers.

But, service providers need custom Dovecot configuration in Linux server to meet user requirements.

However, these customizations often screw up due to incorrect server settings or even a bad firewall.

At Bobcares, we often get requests to set up Dovecot configuration in Linux as part of our Server Management Services.

Today, let’s get into the details and see how our Support Engineers do Dovecot configuration in Linux and fix related errors.


Why use Dovecot?

Dovecot is an open-source IMAP and POP3 email server for Linux. When a server has a Postfix mail server to send mails, then we need a program to retrieve the incoming messages from the server.

Here, we use Dovecot which gets messages from Postfix and delivers them to the corresponding mailbox on the server.

Let’s see how our Support Engineers install and configure Dovecot.

Also, before going to the procedures for Dovecot configuration, we should ensure that the Postfix is installed on the server.

1. Initially, we install the Dovecot package. On a CentOS server, we do it by running the following command.

yum install dovecot

2. Then, we configure the services in the configuration file /etc/dovecot/dovecot.conf. We open the file /etc/dovecot/dovecot.conf and uncomment the following lines in the file.

protocols = imap pop3
mail_location = maildir:~/Maildir

3. After that, we open the authentication process file /etc/dovecot/conf.d/10-auth.conf and uncomment the following line in the file.

auth_mechanisms = plain login

4. Next, we set the location for the mail by editing the configuration file at /etc/dovecot/conf.d/10-mail.conf. We add the following line in the configuration file:

mail_location = maildir:~/Maildir

5. We  comment the following line in /etc/dovecot/conf.d/10-master.conf. 

#unix_listener auth-userdb {
#mode = 0600
#user =
#group =

Then, we uncomment the following lines:

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix

6. Also, we configure the /etc/dovecot/conf.d/20-pop3.conf as uncomment following lines:

pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

7. We restart both services as follows,

/etc/init.d/postfix restart
/etc/init.d/dovecot restart

8. After that, we open the file at /etc/postfix/ and add the following lines.

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

9. At last, we restart the postfix service.

service postfix restart

Again, control panel based servers allow the configuration of Dovecot from web interface too.  For example, on Linux Plesk servers, to set up Dovecot we need to choose it using the installer.


How we fix the errors related to dovecot

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems while configuring dovecot on the server.

Now let’s see the major reasons for Dovecot errors and how our Support Engineers fix the top errors.


1. Wrong server settings

Recently, one of our customers had a problem while restarting the Dovecot in Plesk servers. The Dovecot failed to start with the following error,

/etc/init.d/dovecot start
Starting Dovecot Imap: Error: socket() failed: Address family not supported by protocol
Error: service(managesieve-login): listen(::, 4190) failed: Address family not supported by protocol
Error: socket() failed: Address family not supported by protocol
Error: service(pop3-login): listen(::, 110) failed: Address family not supported by protocol
Error: service(imap-login): listen(::, 993) failed: Address family not supported by protocol
Fatal: Failed to start listeners

While investigating, our Support Engineers found that Dovecot was configured by default to listen to IPv4 and IPv6 interfaces, but the server did not have IPv6 interfaces.

Therefore, we logged in to the server as a root user and created a backup of the current Dovecot configuration file.

cp -a /etc/dovecot/dovecot.conf{,.bak}

Then, we added the following at the beginning of the Dovecot configuration file /etc/dovecot/dovecot.conf.

listen = *

This fixed the error and Dovecot started working fine.


2. Bad firewall settings

Similarly, almost all server owners try to improve their server security with many tools like server firewalls, SSL certificates, etc. However, they may forget to allow connections to port 587. Often these restrictions result in Dovecot failures.

To allow the connection, we need to open the Dovecot server port in iptables.

Therefore, we add the rule for this port with the following command.

iptables -I INPUT 2 -p tcp --dport 587 -j ACCEPT

Also, we add the POP and IMAP ports.

iptables -I INPUT 3 -p tcp --dport 110 -j ACCEPT
iptables -I INPUT 4 -p tcp --dport 143 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 993 -j ACCEPT
iptables -I INPUT 6 -p tcp --dport 995 -j ACCEPT

Finally, we save the iptables rules and restart iptables.

/etc/init.d/iptables save

/etc/init.d/iptables restart


[Having trouble solving Dovecot configuration in Linux errors? We’ll fix it for you.] 



In short, server owners may get errors while doing Dovecot configuration in Linux. Often, these errors may happen due to wrong server settings and bad firewall settings. In this write-up, we discussed the ways in which our Support Engineers fix these Dovecot errors.

Source link


Write A Comment