Install and Configure postfix, dovecot & Squirrelmail on CentOS 7
Sequence 1. Setup Prerequisites
-
- Remove default MTA
sendmail
if it’s already installed.
- Remove default MTA
-
- Add hostname entry in /etc/hosts file:
-
- Disable SELinux to reduce the complexity in postfix configuration.
-
- Install EPEL Repository if not installed
-
- Allow the Apache default port 80 through your firewall/router:
Sequence 2. Install Postfix
Postfix
is a free open source mail transfer agent (MTA). It is fast, secure and easy to administer. It’s an alternative to Sendmail.
-
- Install Postifix using command:
-
- Configuring Postfix by edit /etc/postfix/main.cf file:
-
- Start/restart Postfix service now:
Sequence 3. Testing Postfix mail server
-
- Create a test user called “sangwan“.
-
- Set the password for the user:
-
- Access the server via Telnet and enter the commands manually shown in red colored text.
ehlo localhost # Type this line
250-server1.example.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
mail from: # Mail sender address
250 2.1.0 Ok
rcpt to: # Mail receiver address
250 2.1.5 Ok
data # To input body of Email
354 End data with .
Welcome to TheSkillPedia mail server # Body of the Email
. # After you finished with content
250 2.0.0 Ok: queued as E2B522032F93
quit # Exit from mail
221 2.0.0 Bye Connection closed by foreign host.
-
- Now navigate to the user “sangwan“ mail directory and check whether the new mail has been received.
-
- To read the mail, enter the following command:
Sequence 4. Install Dovecot
Dovecot
is an open source IMAP and POP3 mail server for Unix/Linux systems.
-
- To install it, run:
-
- Configuring Dovecot by editing file /etc/dovecot/dovecot.conf ,
-
- Edit file /etc/dovecot/conf.d/10-mail.conf file
-
- Edit /etc/dovecot/conf.d/10-auth.conf
-
- Edit file /etc/dovecot/conf.d/10-master.conf,
-
- Start Dovecot service:
Sequence 5. Testing Dovecot
-
- Enter the following command in Terminal:
-
- Enter the commands given marked with comment:
user sangwan #Enter the mail user name
+OK
pass centos #Enter the password
+OK Logged in.
retr 1 #Type this command to view mail
+OK 415 octets Return-Path: X-Original-To: sangwan Delivered-To: sangwan@example.com Received: from localhost (localhost [IPv6:::1]) by server1.example.com (Postfix) with ESMTP id E2B522032F93 for ; Fri, 24 Jul 2015 12:42:36 +0530 (IST) Message-Id: <20150724071330.E2B522032F93@server1.example.com> Date: Fri, 24 Jul 2015 12:42:36 +0530 (IST) From: sangwan@example.com Welcome to TheSkillPedia mail server .
quit #Type 'quit' to exit
+OK Logging out. Connection closed by foreign host.
Sequence 6. Install Squirrelmail
[the_ad id="2469"] We can easily send/receive mails using webmail client called
Squirrelmail
via a web browser. Make sure that you’ve installed and enabled EPEL repository.
-
- Install Squirrelmail:
-
- Change to
/usr/share/squirrelmail/config/
and run conf.pl
- Change to
“S”
to save the changes, and press
“R”
to return back to your main menu: SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Organization Preferences 1. Organization Name : TheSkillPedia 2. Organization Logo : ../images/sm_logo.png 3. Org. Logo Width/Height : (308/111) 4. Organization Title : SquirrelMail $version 5. Signout Page : 6. Top Frame : _top 7. Provider link : http://squirrelmail.org/ 8. Provider name : TheSkillPedia Mail R Return to Main Menu C Turn color off S Save data Q Quit Command >> S Then R to return to main menu 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) --------------------------------------------------------- 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 >> 3 Enter “2” to switch from sendmail MTA to postfix. You now need to choose the method that you will use for sending messages in SquirrelMail. You can either connect to an SMTP server or use sendmail directly. 1. Sendmail 2. SMTP Your choice [1/2] [1]: 2 Now enter “S” followed by “Q” to save and exit Squirrelmail configuration.
-
- Create a squirrelmail vhost in apache config file:
-
- Restart the Apache service:
Sequence 7. Access Webmail
Now navigate to
http://ip-address/webmail
or
http://example.com/webmail
from your browser. From this interface, you can send and receive mails to local users on this server.
Complete this lab successfully and avail 80% discount on any course on this website. Drop a mail with screenshot at admin@theskillpedia.com and we will share the discount coupon with you.
Take a look at the Courses offered with Course Contents at https://www.theskillpedia.com/category/course-contents/ [the_ad id="2469"]