{"id":398,"date":"2021-09-27T08:05:28","date_gmt":"2021-09-27T08:05:28","guid":{"rendered":"https:\/\/tiruppurwebhosting.com\/blog\/?p=398"},"modified":"2021-09-27T08:05:55","modified_gmt":"2021-09-27T08:05:55","slug":"easy-way-to-config-local-mail-server-using-post-fix-dovecot-and-squirrel-mail","status":"publish","type":"post","link":"https:\/\/tiruppurwebhosting.com\/blog\/easy-way-to-config-local-mail-server-using-post-fix-dovecot-and-squirrel-mail\/","title":{"rendered":"Easy Way to config  Local Mail Server Using Post fix, Dovecot and Squirrel-mail"},"content":{"rendered":"<p>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.<\/p>\n<p>Before we going to this article we must aware in working emails and web mail through internet.<\/p>\n<p>Post fix\u00a0\u00a0is a free open source mail transfer agent (MTA). It is easy to administer, fast and as well as the secure MTA. It\u2019s an alternative to Send mail, which is the default MTA for RHEL.<\/p>\n<p>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.<\/p>\n<p>For this tutorial, I use CentOS 6.5 32 bit minimal installation, with SELinux disabled.<\/p>\n<p>The details are given below.<\/p>\n<pre class=\"western\">OS         : Cent-OS 6.5 32 bit Minimal Installation (fresh installation)\r\n\r\nIP Address : \r\nHost name   : \r\n<\/pre>\n<p><strong><b>Precondition:<\/b><\/strong><\/p>\n<p>1. Remove default MTA send mail first if it\u2019s already installed. Send mail will not be installed by \u00a0default in minimal installation, so you can skip this step.<\/p>\n<pre># yum remove sendmail<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-295 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture1-2.jpg\" alt=\"\" width=\"476\" height=\"308\" \/><br \/>\n2. 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\u2019ll need to contact your ISP to point your external static IP to your mail domain.<\/p>\n<p>3. Add hostname entries in \/etc\/hosts file as shown below:<\/p>\n<pre># vi \/etc\/hosts<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-297 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/etc-2.jpg\" alt=\"\" width=\"554\" height=\"109\" \/><\/p>\n<p>4. After i disabled SELinux to reduce complexity in post-fix configuration.<\/p>\n<p>5. Install EPEL Repository:<\/p>\n<p>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.<\/p>\n<p>Install EPEL Repository On CentOS \/ RHEL \/ Scientific Linux 6.<\/p>\n<p>6. Allow the Apache default port 80 through your firewall\/router:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-298 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture3-1.jpg\" alt=\"\" width=\"566\" height=\"288\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Install Postfix:<\/h2>\n<p>Let us install postfix package using the command:<\/p>\n<pre># yum install postfix -y<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-299 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture4-1.jpg\" alt=\"\" width=\"389\" height=\"137\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4>Configuring Postfix<\/h4>\n<p>Edit \/etc\/postfix\/main.cf,<\/p>\n<pre># vi \/etc\/postfix\/main.cf<\/pre>\n<p>Modify the following lines and change to:<\/p>\n<pre>## Line no 75 - Un comment and set your mail server\u00a0\r\n\r\nmyhostname =\u00a0\u00a0\r\n\r\n## Line 83 - Un comment and Set domain name\u00a0\r\n\r\nmydomain =\u00a0\u00a0\r\n\r\n## Line 99 - Uncomment\u00a0\r\n\r\n## myorigin = $mydomain\u00a0\r\n\r\n## Line 116 - Set ipv4\u00a0\u00a0\r\n\r\n# inet_interfaces = all\u00a0\r\n\r\n## Line 119 - Change to all\u00a0\r\n\r\n## inet_protocols = all<\/pre>\n<h4><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-300 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/5-1.jpg\" alt=\"\" width=\"560\" height=\"110\" \/><\/h4>\n<pre>## Line 164 - Comment ## #\r\nmydestination = $myhostname, localhost,##\r\nline 165-comment\r\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain\r\n##Line 264 - Uncomment and add IP range\r\nmynetworks = xxx.xx.xxx.xxx\/xx\r\n## Line 419 - Uncomment\r\n## home_mailbox = Maildir\/<\/pre>\n<h4 class=\"western\"><strong><a href=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture6.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-234 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture6.jpg\" alt=\"\" width=\"546\" height=\"53\" \/><\/a><br \/>\nSave and exit the file.<br \/>\nStart\/restart Postfix service now:<\/strong><\/h4>\n<pre># service postfix restart\r\n\r\n# chkconfig postfix on<\/pre>\n<p>Testing Postfix mail server<\/p>\n<p>First, create a test user<\/p>\n<pre># useradd :\r\n\r\n# passwd :\r\n<\/pre>\n<p>Access the server via Telnet and enter the commands manually shown in red colored text.<\/p>\n<pre># telnet localhost smtp\r\nTrying ::1\u2026\r\nConnected to localhost.\r\nEscape character is '^]'.\r\n220 \u00a0xxxxxxxxxxxx ESMTP Postfix\r\nehlo localhost ## type this command ##\r\n250-server.xxxxxx.local\r\n250-PIPELINING\r\n250-SIZE 10240000\r\n250-VRFY\r\n250-ETRN\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250 DSN\r\n<\/pre>\n<h4><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-301 size-full\" src=\"https:\/\/www.coimbatorewebhosting.com\/blog\/wp-content\/uploads\/2017\/07\/Capture7-1.jpg\" alt=\"\" width=\"421\" height=\"281\" \/><\/h4>\n<pre>mail from:&lt;username&gt; ----enter this command\r\n250 2.1.0\u00a0Ok<\/pre>\n<p>rcpt to:&lt;username&gt; \u00a0&#8212;&#8212;&#8212;&#8211;enter this command<\/p>\n<p>250 2.1.5\u00a0 Ok<\/p>\n<p>data \u00a0 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-enter this command<\/p>\n<p>354\u00a0 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;<\/p>\n<p>welcome to \u00a0xxxxxx.xxxxx.in mail server<\/p>\n<p>## Enter the boddy of the email ##. ##<\/p>\n<p>type dot (.) to complete message ##<\/p>\n<p>250 2.0.0 Ok: queued as CT589634782<\/p>\n<p>quit 221 2.0.0 Bye Connection closed by foreign host.<\/p>\n<p>Now navigate to the user : mail directory and check for the new mail:<\/p>\n<pre># ls \/home\/username\/Maildir\/new\/<\/pre>\n<p>Sample output:<\/p>\n<p>45218325715.Vht00Ie0hy58357080.vpstestbalaji.choose2host.in.local<\/p>\n<p>A new mail is received to the user \u00a0name . To read the mail, enter the following command:<\/p>\n<pre># cat \/home\/username\/Maildir\/new\/45218325715.Vht00Ie0hy58357080.xxxxxx.xxxxxx.in<\/pre>\n<h3><strong>Installing Dovecot<\/strong><\/h3>\n<p>Dovecot is an open source IMAP and POP3 mail server for Unix\/Linux systems. To install:<\/p>\n<pre># yum install dovecot<\/pre>\n<p>Configuring Dovecot<\/p>\n<p>Edit the file \/etc\/dovecot\/dovecot.conf file,<\/p>\n<pre># vi \/etc\/dovecot\/dovecot.conf<\/pre>\n<p>Uncomment the following line:<\/p>\n<pre># Line 20 - umcomment ##\r\n\r\nprotocols = imap pop3 lmtp<\/pre>\n<p>Edit file \/etc\/dovecot\/conf.d\/10-mail.conf file<\/p>\n<pre># vi \/etc\/dovecot\/conf.d\/10-mail.conf<\/pre>\n<p>Make the changes as shown below:<\/p>\n<pre>## Line 24 - uncomment ##<\/pre>\n<p>mail_location = maildir:~\/Maildir<\/p>\n<p>Edit \/etc\/dovecot\/conf.d\/10-auth.conf<\/p>\n<pre># vi \/etc\/dovecot\/conf.d\/10-auth.conf<\/pre>\n<p>And make the changes as shown below:<\/p>\n<pre>## line 9 \u2013 uncomment##\r\n\r\ndisable_plaintext_auth = yes\r\n\r\n## Line 97 - Add a letter \"login\" ##\r\n\r\nauth_mechanisms = plain login<\/pre>\n<p>Edit file \/etc\/dovecot\/conf.d\/10-master.conf,<\/p>\n<pre># vi \/etc\/dovecot\/conf.d\/10-master.conf<\/pre>\n<p>Make changes as shown below:<\/p>\n<pre>## Line 83, 84 - Uncomment and add \"postfix\"\r\n\r\n#mode = 0600\r\n\r\nuser = postfix\r\n\r\ngroup = postfix<\/pre>\n<p>Start Dovecot service:<\/p>\n<pre># service dovecot start\r\n\r\n# chk config dovecot on<\/pre>\n<p>Testing Dovecot<\/p>\n<p>It\u2019s time to test Dovecot configuration. Enter the following command in Terminal:<\/p>\n<p># telnet localhost pop3<\/p>\n<p>Enter the commands manually marked in :<\/p>\n<pre>Trying ::1\u2026 Connected to localhost.\r\n\r\nEscape character is '^]'.\r\n\r\n+OK Dovecot ready.<\/pre>\n<p>As you see in the above, Dovecot is working!<br \/>\nWorking 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.<\/p>\n<h3>Installing Squirrel mail:<\/h3>\n<p>Make sure that you\u2019ve installed and enabled EPEL repository. Now install Squirrelmail using the following command:<\/p>\n<pre># yum install squirrelmail -y<\/pre>\n<p>Configuring Squirrelmail<\/p>\n<p>Navigate to \/usr\/share\/squirrelmail\/config\/ directory and run the command conf.pl<\/p>\n<pre># cd \/usr\/share\/squirrelmail\/config\/\r\n\r\n# .\/conf.pl<\/pre>\n<p>The following wizard will open. Enter choice\u201c1\u201d to set your organization details:<\/p>\n<pre>SquirrelMail Configuration : Read: config.php (1.4.0) ---------------------------------------------------------\r\n\r\nMain Menu --\r\n\r\n1. Organization Preferences\r\n\r\n2. Server Settings\r\n\r\n3. Folder Defaults\r\n\r\n4. General Options\r\n\r\n5. Themes\r\n\r\n6. Address Books\r\n\r\n7. Message of the Day (MOTD)\r\n\r\n8. Plugins 9. Database\r\n\r\n10.Languages\r\n\r\nD. Set pre-defined settings for specific IMAP servers\r\n\r\nC Turn color off S Save data\r\n\r\nQ Quit\r\n<\/pre>\n<p>By entering the open commands from 1 to 10 we can easily installed and configured the web mail<br \/>\n(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).<\/p>\n<p>Now enter \u201cS\u201dfollowed by\u201cQ\u201dto save and exit Squirrelmail configuration.<br \/>\nCreate a squirrel mail vhost in Apache con fig file:<\/p>\n<pre># vi \/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p>Add the following lines at the end:<\/p>\n<pre>Alias \/webmail \/usr\/share\/squirrelmail\r\n&lt;Directory \/usr\/share\/squirrelmail&gt;\r\n\tOptions Indexes FollowSymLinks\r\n\tRewrite Engine On\r\n\tAllow Override All\r\n    Directory Index index.php\r\n    Order allow,deny\r\n    Allow from all\r\n&lt;\/Directory&gt;\r\n<\/pre>\n<p>Restart the Apache service:<\/p>\n<pre># service httpd restart<\/pre>\n<p>Create users<\/p>\n<p>Create some users for testing. In my case create users and password to login:<\/p>\n<pre># useradd:\r\n\r\n# passwd:\r\n<\/pre>\n<p>Access Webmail<\/p>\n<p>Now navigate to\u00a0http:\/\/ip-address\/webmail\u00a0or\u00a0http:\/\/domain-name\/webmail\u00a0from your<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0\u00a0is a free open source mail transfer agent (MTA). It is easy<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,92,1],"tags":[],"class_list":["post-398","post","type-post","status-publish","format-standard","hentry","category-basics","category-general","category-home"],"_links":{"self":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=398"}],"version-history":[{"count":0,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/398\/revisions"}],"wp:attachment":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}