This article will explain an easy way to configure the web mail in centos Virtual Private Server by using Post fix, dovecot and Squirrel Mail.
Before we going to this article we must aware in working emails and web mail through internet.
Post fix is a free open source mail transfer agent (MTA). It is easy to administer, fast and as well as the secure MTA. It’s an alternative to Send mail, which is the default MTA for RHEL.
Well, let us see how to setup a basic local mail server using Postfix, Dovecot and Squirrelmail On CentOS 6.5, although it should work on RHEL, Scientific Linux 6.x series.
For this tutorial, I use CentOS 6.5 32 bit minimal installation, with SELinux disabled.
The details are given below.
OS : Cent-OS 6.5 32 bit Minimal Installation (fresh installation) IP Address : Host name :
Precondition:
1. Remove default MTA send mail first if it’s already installed. Send mail will not be installed by default in minimal installation, so you can skip this step.
# yum remove sendmail
2. Setup DNS server and add the Mail server MX records in the forward and reverse zone files. First install and configure DNS server. And you’ll need to contact your ISP to point your external static IP to your mail domain.
3. Add hostname entries in /etc/hosts file as shown below:
# vi /etc/hosts
4. After i disabled SELinux to reduce complexity in post-fix configuration.
5. Install EPEL Repository:
We will use Squirrelmail for webmail client.Squirrelmail will not be found on CentOS official repositories, so let us enable EPEL repository. Follow the below link to install and enable EPEL repository.
Install EPEL Repository On CentOS / RHEL / Scientific Linux 6.
6. Allow the Apache default port 80 through your firewall/router:
Install Postfix:
Let us install postfix package using the command:
# yum install postfix -y
Configuring Postfix
Edit /etc/postfix/main.cf,
# vi /etc/postfix/main.cf
Modify the following lines and change to:
## Line no 75 - Un comment and set your mail server myhostname = ## Line 83 - Un comment and Set domain name mydomain = ## Line 99 - Uncomment ## myorigin = $mydomain ## Line 116 - Set ipv4 # inet_interfaces = all ## Line 119 - Change to all ## inet_protocols = all
## Line 164 - Comment ## # mydestination = $myhostname, localhost,## line 165-comment mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ##Line 264 - Uncomment and add IP range mynetworks = xxx.xx.xxx.xxx/xx ## Line 419 - Uncomment ## home_mailbox = Maildir/
Save and exit the file.
Start/restart Postfix service now:
# service postfix restart # chkconfig postfix on
Testing Postfix mail server
First, create a test user
# useradd : # passwd :
Access the server via Telnet and enter the commands manually shown in red colored text.
# telnet localhost smtp Trying ::1… Connected to localhost. Escape character is '^]'. 220 xxxxxxxxxxxx ESMTP Postfix ehlo localhost ## type this command ## 250-server.xxxxxx.local 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
mail from:<username> ----enter this command 250 2.1.0 Ok
rcpt to:<username> -----------enter this command
250 2.1.5 Ok
data -------------------------------enter this command
354 End data with <CR><LF>.<CR><LF>
welcome to xxxxxx.xxxxx.in mail server
## Enter the boddy of the email ##. ##
type dot (.) to complete message ##
250 2.0.0 Ok: queued as CT589634782
quit 221 2.0.0 Bye Connection closed by foreign host.
Now navigate to the user : mail directory and check for the new mail:
# ls /home/username/Maildir/new/
Sample output:
45218325715.Vht00Ie0hy58357080.vpstestbalaji.choose2host.in.local
A new mail is received to the user name . To read the mail, enter the following command:
# cat /home/username/Maildir/new/45218325715.Vht00Ie0hy58357080.xxxxxx.xxxxxx.in
Installing Dovecot
Dovecot is an open source IMAP and POP3 mail server for Unix/Linux systems. To install:
# yum install dovecot
Configuring Dovecot
Edit the file /etc/dovecot/dovecot.conf file,
# vi /etc/dovecot/dovecot.conf
Uncomment the following line:
# Line 20 - umcomment ## protocols = imap pop3 lmtp
Edit file /etc/dovecot/conf.d/10-mail.conf file
# vi /etc/dovecot/conf.d/10-mail.conf
Make the changes as shown below:
## Line 24 - uncomment ##
mail_location = maildir:~/Maildir
Edit /etc/dovecot/conf.d/10-auth.conf
# vi /etc/dovecot/conf.d/10-auth.conf
And make the changes as shown below:
## line 9 – uncomment## disable_plaintext_auth = yes ## Line 97 - Add a letter "login" ## auth_mechanisms = plain login
Edit file /etc/dovecot/conf.d/10-master.conf,
# vi /etc/dovecot/conf.d/10-master.conf
Make changes as shown below:
## Line 83, 84 - Uncomment and add "postfix" #mode = 0600 user = postfix group = postfix
Start Dovecot service:
# service dovecot start # chk config dovecot on
Testing Dovecot
It’s time to test Dovecot configuration. Enter the following command in Terminal:
# telnet localhost pop3
Enter the commands manually marked in :
Trying ::1… Connected to localhost. Escape character is '^]'. +OK Dovecot ready.
As you see in the above, Dovecot is working!
Working with mail in command modes little bit difficult for us. So we will install a webmail client called Squirrelmail to send/receive emails via a web browser.
Installing Squirrel mail:
Make sure that you’ve installed and enabled EPEL repository. Now install Squirrelmail using the following command:
# yum install squirrelmail -y
Configuring Squirrelmail
Navigate to /usr/share/squirrelmail/config/ directory and run the command conf.pl
# cd /usr/share/squirrelmail/config/ # ./conf.pl
The following wizard will open. Enter choice“1” to set your organization details:
SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Main Menu -- 1. Organization Preferences 2. Server Settings 3. Folder Defaults 4. General Options 5. Themes 6. Address Books 7. Message of the Day (MOTD) 8. Plugins 9. Database 10.Languages D. Set pre-defined settings for specific IMAP servers C Turn color off S Save data Q Quit
By entering the open commands from 1 to 10 we can easily installed and configured the web mail
(squirrel-mail) And by completing the above process we can login by our mail user name and password.we can easily communicate (by sending and receiving the mail message).
Now enter “S”followed by“Q”to save and exit Squirrelmail configuration.
Create a squirrel mail vhost in Apache con fig file:
# vi /etc/httpd/conf/httpd.conf
Add the following lines at the end:
Alias /webmail /usr/share/squirrelmail <Directory /usr/share/squirrelmail> Options Indexes FollowSymLinks Rewrite Engine On Allow Override All Directory Index index.php Order allow,deny Allow from all </Directory>
Restart the Apache service:
# service httpd restart
Create users
Create some users for testing. In my case create users and password to login:
# useradd: # passwd:
Access Webmail
Now navigate to http://ip-address/webmail or http://domain-name/webmail from your browser.