Setting up Dovecot on CentOS/RHEL 6.3

This article will guide you through the installation and configuration steps for Dovecot on CentOS/RHEL 6.3

1) About

Dovecot provides a way for Mail User Agents (MUAs) like Thunderbird, Outlook etc to access their mail. So when a user’s MUA contacts the mail server, the software which answers that request is an IMAP or POP3 server. IMAP and POP3 servers take requests from MUAs and answer those requests by accessing e-mail messages stored on the server and feeding them out to the MUA using IMAP or POP3.
Dovecot presents mail already stored on the system to MUA’s (Thunderbird, Outlook etc) via a commanly used protocol such as IMAP and POP3. Dovecot is not responsible for mail delivery or storage.

There are two primary storage options of mail in the *NIX world: mbox and Maildir. mbox stores multiple messages – sometimes hundreds or thousands of messages – in a single file. Maildir stores each message a separate file. mbox and Maildir have wide support across various e-mail software including MTAs and MDAs, and are both fully supported by Dovecot.

2) Prerequisite
2.1) MTA setup should exists, please check my tutorial for installing Sendmail as an MTA.
2.2) Install the following dependent package:

   # yum install telnet mailx mutt


3) Installation
3.1) Check if dovecot is installed or not:

   # rpm –qa | grep dovecot


3.2) If it is not installed, then install the dovecot package using following command:

   # yum install dovecot


4) Configuration
4.1) By default dovecot configuration files are located at /etc/dovecot.
4.2) Open the dovecot config file /etc/dovecot/dovecot.conf. Find and uncomment/change the line as shown below.

   # vi /etc/dovecot/dovecot.conf
   From:
   #protocols = imap pop3 lmtp
   
   To:
   protocols = imap pop3

4.3) Open the dovecot config file /etc/dovecot/conf.d/10-mail.conf. Find and uncomment/change the line as shown below.

   # vi /etc/dovecot/conf.d/10-mail.conf
   From
   #mail_location =

   To
   mail_location = mbox:~/mail:INBOX=/var/mail/%u


4.4) Restart Dovecot Service:

   # service dovecot restart

4.6) Check the service is running and ports are opened, using following command:

   # ps -ef | grep -v grep | grep -i dovecot
   root      3349     1  0 14:36 ?        00:00:00 /usr/sbin/dovecot
   dovecot   3351  3349  0 14:36 ?        00:00:00 dovecot/anvil
   root      3352  3349  0 14:36 ?        00:00:00 dovecot/log
   root      3353  3349  0 14:36 ?        00:00:00 dovecot/ssl-params
   root      3354  3349  0 14:36 ?        00:00:00 dovecot/config

   # netstat -planet | grep -i dove
   tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      0          320865     3349/dovecot        
   tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      0          320871     3349/dovecot        
   tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      0          320873     3349/dovecot        
   tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      0          320867     3349/dovecot

5) Validation and Testing
5.1) Create two test user for testing purpose (that will send and receive mail):

   # useradd testuser1
   # useradd testuser2


5.2) Login as one of the user (say testuser1) and try to send mail using *mail* command:

   $ mail -s "Test mail from testuser1" testuser2
   Hello this is the test mail
   .
   EOT

5.3) Once mail has been delivered successfully now we need to check if mail is delivered to user (testuser2) mailbox or not
Login as user testuser2 and use *mutt* command to check mail We would see something like the following output:

   $ mutt -f imap://testuser2:PASSWORD@localhost
   1     Aug 19 root            (0.5K) test mail
   2     Aug 19 ganglia@xyz.com (0.3K) Sendmail Test
   3     Aug 19 root            (0.5K) Test mail2

6) Firewall Rule:

6.1) Firewall port that needs to be open for dovecot daemon machine:

   # iptables -A INPUT -p tcp -m tcp –dport 110 -j ACCEPT
   # iptables -A INPUT -p tcp -m tcp –dport 143 -j ACCEPT
   # iptables -A INPUT -p tcp -m tcp –dport 993 -j ACCEPT
   # iptables -A INPUT -p tcp -m tcp –dport 995 -j ACCEPT

6.2) Save the Iptables rules and restart it.

   service iptables save
   service iptables restart


Related Posts:
Setting up Sendmail on CentOS/RHEL 6.3

Advertisements

2 thoughts on “Setting up Dovecot on CentOS/RHEL 6.3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s