Setup Mail Server using Postfix, Dovecot and SquirrelMail in CentOS/RHEL/Scientific Linux 6.5 step by step
The mail server should contain a valid MX record in the DNS server. Navigate to my previous DNS SERVER link
- · Firewall and SELinux should be disabled.[root@ansh ~]# service iptables stop[root@ansh ~]# service ip6tables stop[root@ansh ~]# chkconfig iptables off[root@ansh ~]# chkconfig ip6tables off[root@ansh ~]# vi /etc/selinux/config# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targetedReboot the server.ScenarioIn this tutorial my test boxHostname = ansh.kirtipatel.comIP Address = 192.168.1.200/24And my server is configured with proper MX record in DNS server.InstallationPostfix is installed by default. If it is not installed, use the below command to install postfix.[root@ansh ~]# yum install postfixConfigurationOpen the postfix config file /etc/postfix/main.cf. Find the below lines and edit them as shown below.[root@server ~]# vi /etc/postfix/main.cfmyhostname =ansh.kirtipatel.com ##line no 75 - uncomment and enter your host namemydomain = kirtipatel.com ##line no 83 - uncomment and enter your domain namemyorigin = $mydomain ##line no 99 - uncommentinet_interfaces = all ##line no 116 - change to allmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ##line no 164 - add $domain at the endmynetworks = 192.168.1.0/24, 127.0.0.0/8 ##line no 264 - uncomment and add your network rangehome_mailbox = Maildir/ ##line no 419 - uncommentStart the postfix service.[root@server ~]# service postfix startStarting postfix: [ OK ][root@server ~]# chkconfig postfix onTest PostfixThe commands shown in bold letters should be entered by the user.Note: The dot after the test command is important.[root@server ~]# telnet localhost smtpTrying ::1...Connected to localhost.Escape character is '^]'.220 ansh.kirtipatel.com ESMTP Postfixehlo localhost250-ansh.kirtipatel.com250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNmail from:<user1>250 2.1.0 Okrcpt to:<user1>250 2.1.5 Okdata354 End data with <CR><LF>.<CR><LF>test
.250 2.0.0 Ok: queued as 117113FF18quit221 2.0.0 ByeConnection closed by foreign host.Check MailNavigate to the user mail directory and check for the new mail.[root@server ~]# cd /home/user1/Maildir/new/[root@server new]# ls1360236956.Vfd00I35afM181256.ansh.kirtipatel.com[root@server new]# cat 1360236956.Vfd00I35afM181256.ansh.kirtipatel.comReturn-Path: <user1@kirtipatel.com>X-Original-To: user1Delivered-To: user1@kirtipatel.comReceived: from localhost (localhost [IPv6:::1])by ansh.kirtipatel;.com (Postfix) with ESMTP id 117113FF18for <user1>; Thu, 7 Feb 2013 17:05:32 +0530 (IST)Message-Id: <20130207113547.117113FF18@ansh.kirtipatel.com>Date: Thu, 7 Feb 2013 17:05:32 +0530 (IST)From: user1@kirtipatel.comTo: undisclosed-recipients:;testThats it. Postfix working now.Install Dovecot[root@server ~]# yum install dovecotConfigure DovecotOpen the dovecot config file /etc/dovecot/dovecot.conf. Find and uncomment the line as shown below.[root@server ~]# vi /etc/dovecot/dovecot.confprotocols = imap pop3 lmtpOpen the file /etc/dovecot/conf.d/10-mail.conf and uncomment the line as shown below.[root@server ~]# vi /etc/dovecot/conf.d/10-mail.confmail_location = maildir:~/Maildir ##line no 24 - uncommentOpen the /etc/dovecot/conf.d/10-auth.conf and edit as shown below.[root@server ~]# vi /etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = no ##line no 9 - uncomment and change from yes to no.auth_mechanisms = plain login ##line no 97 - add the text "login"Open the /etc/dovecot/conf.d/10-master.conf and edit as shown below.unix_listener auth-userdb {#mode = 0600user = postfix ##line no 83 - uncomment and enter postfixgroup = postfix ##line no 84 - uncomment and enter postfixStart the dovecot service.[root@server ~]# service dovecot startStarting Dovecot Imap: [ OK ][root@server ~]# chkconfig dovecot onTest DovecotThe commands shown in bold should be entered by the user.[root@server ~]# telnet localhost pop3Trying ::1...Connected to localhost.Escape character is '^]'.+OK Dovecot ready.user user1+OKpass user1+OK Logged in.list+OK 1 messages:1 428.retr 1+OK 428 octetsReturn-Path: <user1@kirtipatel.com>X-Original-To: user1Delivered-To: user1@kirtipatel.comReceived: from localhost (localhost [IPv6:::1])by ansh.kirtipatel.com (Postfix) with ESMTP id 117113FF18for <user1>; Thu, 7 Feb 2013 17:05:32 +0530 (IST)Message-Id: <20130207113547.117113FF18@ansh.kirtipatel.com>Date: Thu, 7 Feb 2013 17:05:32 +0530 (IST)From: user1@kirtipatel.comTo: undisclosed-recipients:;test
.
quit+OK Logging out.Connection closed by foreign host.[root@server ~]#Dovecot is working now.Install SquirrelmailInstall EPEL repository first. And install SquirrelMail package from EPEL repository.[root@ansh ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm[root@ansh~]# rpm -ivh epel-release-6-8.noarch.rpm[root@ansh~]# yum install squirrelmail[root@ansh~]# service httpd startStarting httpd: [ OK ][root@ansh ~]# chkconfig httpd onConfigure SquirrelmailGo to the squirrelmail config directory and use the command ./conf.pl to start configure as shown below.[root@server ~]# cd /usr/share/squirrelmail/config/[root@server config]# ./conf.plSquirrelMail Configuration : Read: config.php (1.4.0)---------------------------------------------------------Main Menu --1. Organization Preferences2. Server Settings3. Folder Defaults4. General Options5. Themes6. Address Books7. Message of the Day (MOTD)8. Plugins9. Database10. LanguagesD. Set pre-defined settings for specific IMAP serversC Turn color offS Save dataQ QuitCommand >>1Select option 1 and set organization details.SquirrelMail Configuration : Read: config.php (1.4.0)---------------------------------------------------------Organization Preferences1. Organization Name : KIRTIPATEL2. Organization Logo : ../images/sm_logo.png3. Org. Logo Width/Height : (308/111)4. Organization Title : Welcome to Kirti Patel webmail5. Signout Page :6. Top Frame : _top7. Provider link : http://kirtipatel.com8. Provider name :KirtipatelR Return to Main MenuC Turn color offS Save dataQ QuitCommand >>RPress R to return main menu and select option 2. Enter your domain name and select dovecot in the Sendmail or SMTP parameter.SquirrelMail Configuration : Read: config.php (1.4.0)---------------------------------------------------------Server SettingsGeneral-------1. Domain : kirtipatel.com2. Invert Time : false3. Sendmail or SMTP : SMTPA. Update IMAP Settings : localhost:143 (uw)B. Update SMTP Settings : localhost:25R Return to Main MenuC Turn color offS Save dataQ QuitCommand >> SOnce you done, press S to save datas and press Q to exit.Add the following lines in the httpd.conf file at the end.[root@server ~]# vi /etc/httpd/conf/httpd.confAlias /squirrelmail /usr/share/squirrelmail<Directory /usr/share/squirrelmail>Options Indexes FollowSymLinksRewriteEngine OnAllowOverride AllDirectoryIndex index.phpOrder allow,denyAllow from all</Directory>Restart the httpd service.[root@ansh ~]# service httpd restartStopping httpd: [ OK ]Starting httpd: [ OK ][root@ansh ~]#Create Users[root@ansh~]# useradd user1[root@ansh~]# useradd user2[root@ansh~]# passwd user1[root@ansh~]# passwd user2Open the browser from any clients. Type the following in the address bar.http://serveripaddress/webmailorhttp://yourdomainname/webmail
After that you can login with your username and password.. and u can see this next screen.
Comments
Post a Comment