Bobcares

Dovecot configuration in Linux – An effective way to set up

by | Sep 4, 2019

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/main.cf 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
[FAILED]

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.] 

 

Conclusion

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.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF