Installing Dovecot and Squirrelmail in CentOS & SientificLinux

Note: This tutorial is a continuation of the Sendmail tutorial; please read through the Sendmail tutorial first before you attempt to install Dovecot or Squirrelmail.

Although most versions of CentOS come standard with a POP3/IMAP server, dovecot can be much easier to configure and works almost straight after installation. Both the POP3 and IMAP protocols are primarily used for receiving emails on a mail server, almost all mail servers these days support both protocols; however there is a slight difference between the two. The main different between these protocols is that the POP3 protocol retrieves the whole email for the client, once

the emails are retrieved they removed from the server; where as a IMAP stores only the header information on the client side and changes to the email can be kept track of. There are some advantages and disadvantages of each protocol; however I will leave it up to your discretion which you would prefer to use.

First things first, you will need to start out by installing both Dovecot and Squirrelmail using yum.

yum –y install dovecot squirrelmail

Next you will need to set the dovecot service to start on reboot and turn the service on

chkconfig dovecot on
service dovecot start

 You will also need to edit the dovecot configuration file to setup mail boxes for each user. The configuration file is located at /etc/dovecot.conf

 mail_location = maildir:~/Maildir
mail_location = mbox:~/mail:INBOX=/var/mail/%u

Restart dovecot so that the changes will take effect.

 You will also need Apache and PHP installed in order to run Squirrelmail. To check if Apache is installed enter the following command:

 rpm –qa httpd
rpm –qa php

 CentOS generally comes installed with Apache and PHP however, if they are not installed for some reason you can use the following command to install them.

 yum –y install httpd php

 Next you will need to create a symbolic link of the Squirrelmail folder to the Apache root directory.

 ln –s /usr/share/squirremail /var/www/html/mail

 Then you will need to browse to the config directory to run the configuration script.

 cd /usr/share/squirrelmail/config
./conf.pl

 

You will now need to go through the settings menu and choose the appropriate configuration for your server; you should not need to change much except for your domain name in server settings.

 Finally you will need to modify your Apache configuration file to set an alias and allow for SymLinks so that Apache can read the files in the /mail directory. You can do this by adding the following lines to /etc/httpd/conf/httpd.conf

 

Alias /mail/ "/usr/share/squirrelmail/"
 <Directory "/usr/share/squirrelmail">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

 

You will also need to restart Apache for these settings to take effect

 service httpd restart

 

You should be able to visit your Squirrelmail installation now by visiting your http://yourip/mail or http://example.com/mail and login using your username and password.

 

 If you are connecting via a mail client such as outlook or thunderbird you can connect using IMAP or POP3 using your IP address, however it’s probably a good idea to create DNS records for both protocols. For my mail server I created two A records pop.example.com and imap.example.com, make sure that both records point to your server.

{module user9-footer}