Install and Configure Postfix, Dovecot & Squirrelmail on CentOS 7

SHORT INTRODUCTION

Postfix is a popular open source email referral source that can be used to send and send emails to a Linux system. It is estimated that about 25% of online public servers use Postfix.

Installing Required Software Packages

It enables the user to install valuable packages that are not shipped with the official repository of Enterprise Linux.

[root@fosnix ~]# yum install epel-release -y

Firstly remove default MTA Sendmail if it’s already installed. by running the command.

[root@fosnix ~]# yum remove postfix -y

Add hostname entry in /etc/hosts file:

[root@fosnix ~]# vi /etc/hosts

Disable SELinux to reduce the complexity in postfix configuration

[root@fosnix ~]# setenforce 0

Allow the Apache default port 80 through your firewall/router

[root@fosnix ~]# firewall-cmd --permanent --add-port=80/tcp
[root@fosnix ~]# firewall-cmd --reload

Install Postfix

[root@fosnix ~]# yum install postfix -y

Configuring Postfix by edit /etc/postfix/main.cf file:

[root@fosnix ~]# vi /etc/postfix/main.cf
myhostname = fosnix.mail.com
mydomain = mail.com # Line 85 - Uncomment and Set domain name
myorigin = $mydomain # Line 101 - Uncomment
inet_interfaces = all # Line 115 - Uncomment and Set ipv4
inet_protocols = all # Line 121 - Change to all
# Line 166 - Comment
#mydestination = $myhostname, localhost.$mydomain, localhost,
# Line 167 - Uncomment
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.1.0/24, 127.0.0.0/8
# Line 266 - Uncomment & add IP range
home_mailbox = Maildir/ # Line 421 - Uncomment

Start/restart Postfix service now:

[root@fosnix ~]# systemctl restart postfix
[root@fosnix ~]# systemctl enable postfix
[root@fosnix ~]# systemctl status postfix

Install Dovecot 

[root@fosnix ~]# yum install dovecot -y

Configuring Dovecot by editing file /etc/dovecot/dovecot.conf 

[root@fosnix ~]# vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp # Line 24 - umcomment

Edit file /etc/dovecot/conf.d/10-mail.conf file

[root@fosnix ~]# vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir # Line 24 - uncomment

Edit /etc/dovecot/conf.d/10-auth.conf

[root@fosnix ~]# vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = yes #line 10 - uncomment
auth_mechanisms = plain login #Line 100 - Add the word: "login"

Edit file /etc/dovecot/conf.d/10-master.conf

[root@fosnix ~]# vi /etc/dovecot/conf.d/10-master.conf#Line 91, 92 - Uncomment and add "postfix"
#mode = 0600
user = postfix
group = postfix

Start Dovecot service:

[root@fosnix ~]# systemctl enable dovecot
[root@fosnix ~]# systemctl start dovecot

Install Squirrelmail

[root@fosnix ~]# yum install squirrelmail -y

Change to /usr/share/squirrelmail/config/ and run conf.pl

[root@fosnix ~]# cd /usr/share/squirrelmail/config/
[root@fosnix ~]# ./conf.pl
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
Command >> 2
Enter “1”, Enter your mail domain (ex. TheSkillPedia. local) and press Enter key.
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain : localhost
2. Invert Time : false
3. Sendmail or SMTP : Sendmail
A. Update IMAP Settings : localhost:143 (uw)
B. Change Sendmail Config : /usr/sbin/sendmail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> 1
The domain name is the suffix at the end of all email addresses. If
for example, your email address is jdoe@example.com, then your domain
would be example.com.
[localhost]: example.com
Enter “3” and change from sendmail to Postfix MTA (i.e. SMTP):
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Now enter “S” followed by “Q” to save and exit Squirrelmail configuration.
Server Settings
General
-------
1. Domain : example.com
2. Invert Time : false
3. Sendmail or SMTP : Sendmail
A. Update IMAP Settings : localhost:143 (uw)
B. Change Sendmail Config : /usr/sbin/sendmail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> S
General
-------
1. Domain : example.com
2. Invert Time : false
3. Sendmail or SMTP : Sendmail
A. Update IMAP Settings : localhost:143 (uw)
B. Change Sendmail Config : /usr/sbin/sendmail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >> Q

Create a squirrelmail vhost in apache config file:

[root@fosnix ~]# vi /etc/httpd/conf/httpd.conf

Add the following lines at the end:

Alias /webmail /usr/share/squirrelmail
Options Indexes FollowSymLinks
RewriteEngine On
AllowOverride All
DirectoryIndex index.php
Order allow,deny
Allow from all

Restart the Apache service:

[root@fosnix ~]# systemctl restart httpd

Access Webmail

Now navigate to http://ip-address/webmail or http://domain-name/webmail from your browser.

LOGIN WITH YOUR USERNAME AND PASSWD

Leave a Reply

Your email address will not be published.