{"id":219,"date":"2017-07-16T00:13:15","date_gmt":"2017-07-16T00:13:15","guid":{"rendered":"http:\/\/jaipurhosting.com\/blog\/?p=219"},"modified":"2019-04-29T15:52:12","modified_gmt":"2019-04-29T10:22:12","slug":"setup-mail-server-centos-6","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/setup-mail-server-centos-6\/","title":{"rendered":"Setup mail server in centos 6"},"content":{"rendered":"<p><strong>Description :<\/strong><\/p>\n<p>This article describes how to setup a mail server in centos 6<\/p>\n<p>Here three popular packages used for configuration<\/p>\n<ul>\n<li>Postfix ( for sending )<\/li>\n<li>Dovecot ( for receiving )<\/li>\n<li>Squirrelmail ( for webmail access )<\/li>\n<\/ul>\n<p><strong>Installing and configuring postfix&nbsp;<\/strong><\/p>\n<p><strong>Step 1 :<\/strong> Before installation assign a static ip and add a host entry for your domain to that IP in the <strong>\/etc\/hosts<\/strong><\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">123.45.67.89 domainname.com<\/pre>\n<p><strong>Step 2 :<\/strong> Issue the below command to install postfix<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# yum -y install postfix<\/pre>\n<p><strong>Step 3 :<\/strong> Now issue the below command to install SMTP AUTH packages<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain<\/pre>\n<p><strong>Postfix<\/strong> package installation is completed.<\/p>\n<p><strong>Step 4 :<\/strong> Issue the below commands one by one for creating SSL Certificate.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# mkdir \/etc\/postfix\/ssl\n[root@mail ~]# cd \/etc\/postfix\/ssl\/\n[root@mail ssl]# openssl genrsa -des3 -rand \/etc\/hosts -out smtpd.key 1024\n[root@mail ssl]# chmod 600 smtpd.key\n[root@mail ssl]# openssl req -new -key smtpd.key -out smtpd.csr\n[root@mail ssl]# openssl x509 -req -days 365 -in smtpd.csr -signkey smtpd.key -out smtpd.crt\n[root@mail ssl]# openssl rsa -in smtpd.key -out smtpd.key.unencrypted\n[root@mail ssl]# mv -f smtpd.key.unencrypted smtpd.key\n[root@mail ssl]# openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 365<\/pre>\n<p><strong>Step 5 :<\/strong> Now open \/etc\/postfix\/main.cf file.<\/p>\n<p>Find and comment the below lines.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">#inet_interfaces = localhost #---&gt; line no 116\n#mydestination = $myhostname, localhost.$mydomain, localhost #--&gt; line no 164<\/pre>\n<p>and add these lines at the bottom of the file.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">myhostname = mail.domainname.com\nmydomain = domainname.com\nmyorigin = $mydomain\nhome_mailbox = mail\/\nmynetworks = 127.0.0.0\/8\ninet_interfaces = all\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain\nsmtpd_sasl_auth_enable = yes\nsmtpd_sasl_type = cyrus\nsmtpd_sasl_security_options = noanonymous\nbroken_sasl_auth_clients = yes\nsmtpd_sasl_authenticated_header = yes\nsmtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination\nsmtpd_tls_auth_only = no\nsmtp_use_tls = yes\nsmtpd_use_tls = yes\nsmtp_tls_note_starttls_offer = yes\nsmtpd_tls_key_file = \/etc\/postfix\/ssl\/smtpd.key\nsmtpd_tls_cert_file = \/etc\/postfix\/ssl\/smtpd.crt\nsmtpd_tls_CAfile = \/etc\/postfix\/ssl\/cacert.pem\nsmtpd_tls_received_header = yes\nsmtpd_tls_session_cache_timeout = 3600s\ntls_random_source = dev:\/dev\/urandom<\/pre>\n<p><strong>Step 6 :<\/strong> Now open \/etc\/postfix\/master.cf file and add the below line after smt<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">smtps inet n - n - - smtpd\n-o smtpd_sasl_auth_enable=yes\n-o smtpd_reject_unlisted_sender=yes\n-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject\n-o broken_sasl_auth_clients=yes<\/pre>\n<p><strong>Step 7 :<\/strong> Now start postfix and saslauthd service<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# service postfix start<\/pre>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# service saslauthd start<\/pre>\n<p>Enter&nbsp;the below commands to start the postfix and saslauthd at startup<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# chkconfig --level 235 postfix on<\/pre>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# chkconfig --level 235 saslauthd on<\/pre>\n<p><strong>Step 8 :<\/strong> Now check your smtp connectivity . just telnet localhost on port 25 and type this command&nbsp;<strong>ehlo localhost<\/strong><\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# telnet localhost 25\nTrying ::1...\nConnected to localhost.\nEscape character is '^]'.\n220 mail.domainname.com ESMTP Postfix\nehlo localhost &lt;---- type this command \n250-mail.domainname.com\n250-PIPELINING\n250-SIZE 10240000\n250-VRFY\n250-ETRN\n250-STARTTLS\n250-AUTH PLAIN LOGIN\n250-AUTH=PLAIN LOGIN\n250-ENHANCEDSTATUSCODES\n250-8BITMIME\n250 DSN\nquit\n221 2.0.0 Bye\nConnection closed by foreign host.<\/pre>\n<p><strong>Installing and configuring dovecot :&nbsp;<\/strong><\/p>\n<p><strong>Step 9 :<\/strong> Issue this command to install dovecot<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# yum -y install dovecot<\/pre>\n<p><strong>Step 10 :<\/strong> After installation open <strong>\/etc\/dovecot\/dovecot.conf<\/strong> file and add the below line at the end of the file.<br \/>\nMake sure mail_location and home_mailbox in postfix configuration are using the same name.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">protocols = imap pop3\nmail_location = maildir:~\/mail\npop3_uidl_format = %08Xu%08Xv<\/pre>\n<p><strong>Step 11 :<\/strong> Now start dovecot service<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# service dovecot start<\/pre>\n<p>Enter&nbsp;the below command to start the dovecot at startup<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# chkconfig --level 235 dovecot on<\/pre>\n<p><strong>Step 12 :<\/strong> Now test your pop3 connectivity.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# telnet localhost 110\nTrying ::1...\nConnected to localhost.\nEscape character is '^]'.\n+OK Dovecot ready.\nquit\n+OK Logging out\nConnection closed by foreign host.<\/pre>\n<p>Now the server is ready to receive mails.<\/p>\n<p><strong>Creating users and testing :&nbsp;<\/strong><\/p>\n<p><strong>Step 13 :<\/strong> Now create users to test your configuration.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# useradd -m user1 -s \/sbin\/nologin<\/pre>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# useradd -m user2 -s \/sbin\/nologin<\/pre>\n<p>and create passwords for the users created<\/p>\n<pre class=\"theme:dark-terminal line-height:440 lang:default decode:true \">[root@mail ~]# passwd user1<\/pre>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# passwd user2<\/pre>\n<p><strong>Step 14 :<\/strong> Test your configuration in thunderbird.<br \/>\nRefer the below image for configuration details.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-220\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/1-2.png\" alt=\"\" width=\"715\" height=\"396\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/1-2.png 715w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/1-2-300x166.png 300w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<p><strong>Step 15 :<\/strong> Now you can send and receive mails using this server. In case of any issues please check the log file<br \/>\n\/var\/log\/maillog )<\/p>\n<p>Now mail server is ready to use<\/p>\n<p><strong>Installing and configuring squirrelmail :&nbsp;<\/strong><\/p>\n<p><strong>Step 16 :<\/strong>&nbsp;We need to add EPEL repository to install squirrelmail package.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# rpm -ivh http:\/\/ftp.jaist.ac.jp\/pub\/Linux\/Fedora\/epel\/6\/i386\/epel-release-6-8.noarch.rpm<\/pre>\n<p><strong>Step 17 :<\/strong> Issue the below command to install squirrelmail.<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# yum install squirrelmail<\/pre>\n<p>This command will install squirrelmail along with apache and php.<\/p>\n<p><strong>Step 18 :<\/strong> Now run the below command to configure squirrelmail .<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# perl \/usr\/share\/squirrelmail\/config\/conf.pl<\/pre>\n<p>=&gt; 1 =&gt; domain (type Organization name) =&gt; R (return)<br \/>\n=&gt; 2 =&gt; 1 =&gt; ( hit space for empty Domain name ) =&gt; choose 3 =&gt; SMTP ( choose SMTP ) =&gt; R (return)<\/p>\n<p>=&gt; D =&gt; dovecot (tyoe) =&gt; Press enter with default<\/p>\n<p>=&gt; s (save and quit)<\/p>\n<p><strong>Step 19 :<\/strong> Open \/etc\/httpd\/conf.d\/squirrelmail.conf file and uncomment below lines<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \"># RewriteCond %{HTTPS} !=on\n# RewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}<\/pre>\n<p><strong>Step 20 :<\/strong>&nbsp;Start apache service<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# service httpd start<\/pre>\n<p>Enter the below commands to start the httpd at startup<\/p>\n<pre class=\"theme:dark-terminal line-height:40 lang:default decode:true \">[root@mail ~]# chkconfig --level 235 httpd on<\/pre>\n<p><strong>Step 21 :<\/strong> Now open http:\/\/serverip\/webmail path in your browser.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-221\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2.png\" alt=\"\" width=\"583\" height=\"288\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2.png 583w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/2-300x148.png 300w\" sizes=\"auto, (max-width: 583px) 100vw, 583px\" \/><\/p>\n<p>and after login<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-222\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/3.jpg\" alt=\"\" width=\"600\" height=\"225\" srcset=\"https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/3.jpg 600w, https:\/\/www.jaipurhosting.com\/blog\/wp-content\/uploads\/2017\/07\/3-300x113.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>****<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description : This article describes how to setup a mail server in centos 6 Here three popular packages used for configuration Postfix ( for sending ) Dovecot ( for receiving ) Squirrelmail ( for webmail access ) Installing and configuring postfix&nbsp; Step 1 : Before installation assign a static ip and add a host entry [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1012,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":2,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"predecessor-version":[{"id":1575,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/219\/revisions\/1575"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1012"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}