{"id":775,"date":"2015-05-12T01:56:01","date_gmt":"2015-05-12T10:56:01","guid":{"rendered":"http:\/\/blog.box.kr\/?p=775"},"modified":"2015-05-12T01:56:01","modified_gmt":"2015-05-12T10:56:01","slug":"setup-mail-server-on-centos-7","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=775","title":{"rendered":"Setup mail server on centos 7"},"content":{"rendered":"<h1><\/h1>\n<div class=\"post-content2\">This article helps you to install and configure basic mail server on <a title=\"Centos\" href=\"http:\/\/www.centos.org\/\">Centos<\/a> 7. Here i have used Postfix for SMTP, Dovecot for POP\/IMAP and Dovecot SASL for SMTP AUTH.<br \/>\nBefore proceeding please make sure you have assigned static IP for the server and have internet connectivity for installing packages.<\/p>\n<h1>Setup mail server on centos 7<\/h1>\n<p>1. <a href=\"http:\/\/www.krizna.com\/centos\/setup-mail-server-centos-7\/#install\">Installing packages<\/a><br \/>\n2. <a href=\"http:\/\/www.krizna.com\/centos\/setup-mail-server-centos-7\/#postfix\">Postfix configuration<\/a><br \/>\n3. <a href=\"http:\/\/www.krizna.com\/centos\/setup-mail-server-centos-7\/#dovecot\">Dovecot configuration<\/a><br \/>\n4. <a href=\"http:\/\/www.krizna.com\/centos\/setup-mail-server-centos-7\/#user\">User creation<\/a><\/p>\n<h2>Installing packages<a name=\"install\"><\/a><\/h2>\n<p><strong>Step 1 \u00bb<\/strong> Assign hostname for the server using the below command.<br \/>\n<code>[root@krizna ~]# hostnamectl set-hostname mail.krizna.com<\/code><br \/>\n<strong>Step 2 \u00bb<\/strong> Make a host entry with your IP in <strong>\/etc\/hosts<\/strong> file.<br \/>\n<code>172.27.0.51 mail.krizna.com<\/code><br \/>\n<strong>Step 3 \u00bb<\/strong> Now start installing packages.<br \/>\n<code>[root@krizna ~]# yum -y install postfix dovecot<\/code><br \/>\nAfter package installation continue with postfix configuration.<\/p>\n<h2>Postfix configuration<a name=\"postfix\"><\/a><\/h2>\n<p>First create SSL certificate for encryption.<br \/>\n<strong>Step 4 \u00bb<\/strong> Follow the below steps one by one for creation.<br \/>\n<code>[root@mail ~]# mkdir \/etc\/postfix\/ssl<br \/>\n[root@mail ~]# cd \/etc\/postfix\/ssl<br \/>\n[root@krizna ssl]# openssl genrsa -des3 -out server.key 2048<br \/>\n[root@krizna ssl]# openssl rsa -in server.key -out server.key.insecure<br \/>\n[root@krizna ssl]# mv server.key server.key.secure<br \/>\n[root@krizna ssl]# mv server.key.insecure server.key<\/code>Leave blank for <strong>A challenge password []<\/strong> value in the below step.<br \/>\n<code>[root@krizna ssl]# openssl req -new -key server.key -out server.csr<br \/>\n[root@krizna ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt<\/code><br \/>\n<strong>Step 5 \u00bb<\/strong> Now open <strong>\/etc\/postfix\/main.cf<\/strong> file for changes.<br \/>\nFind and uncomment the below lines.<br \/>\n<code>#inet_interfaces = localhost #---&gt; line no 116<br \/>\n#mydestination = $myhostname, localhost.$mydomain, localhost #--&gt; line no 164<\/code><br \/>\nand add below lines at the end of the file. change <strong>myhostname<\/strong> and <strong>mydomain<\/strong>values with yours and <strong>home_mailbox<\/strong> value to your desired directory. Here it will store mails in the users home directory (Eg: \/home\/john\/mail ).<\/p>\n<div id=\"crayon-552f205ddd2cb553409228\" class=\"crayon-syntax crayon-theme-cg-cookie crayon-font-monospace crayon-os-pc print-yes notranslate\" data-settings=\" no-popup minimize scroll-always\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<\/div>\n<div class=\"crayon-plain-wrap\">\n<\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"hide\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-1\">1\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-2\">2\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-3\">3\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-4\">4\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-5\">5\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-6\">6\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-7\">7\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-8\">8\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-9\">9\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-10\">10\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-11\">11\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-12\">12\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-13\">13\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-14\">14\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-15\">15\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-16\">16\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-17\">17\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-18\">18\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-19\">19\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-20\">20\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-21\">21\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-22\">22\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2cb553409228-23\">23\n<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-552f205ddd2cb553409228-1\" class=\"crayon-line\"><span class=\"crayon-v\">myhostname<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-v\">mail<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-v\">krizna<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-e\">com<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-2\" class=\"crayon-line\"><span class=\"crayon-v\">mydomain<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-v\">krizna<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-e\">com<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-3\" class=\"crayon-line\"><span class=\"crayon-v\">myorigin<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">$<\/span><span class=\"crayon-e\">mydomain<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-4\" class=\"crayon-line\"><span class=\"crayon-v\">home_mailbox<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-v\">mail<\/span><span class=\"crayon-o\">\/<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-5\" class=\"crayon-line\"><span class=\"crayon-v\">mynetworks<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-cn\">127.0.0.0<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-cn\">8<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-6\" class=\"crayon-line\"><span class=\"crayon-v\">inet_interfaces<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">all<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-7\" class=\"crayon-line\"><span class=\"crayon-v\">mydestination<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">$<\/span><span class=\"crayon-v\">myhostname<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-v\">localhost<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-sy\">$<\/span><span class=\"crayon-v\">mydomain<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-v\">localhost<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-sy\">$<\/span><span class=\"crayon-e\">mydomain<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-8\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_sasl_type<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">dovecot<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-9\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_sasl_path<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-m\">private<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-e\">auth<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-10\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_sasl_local_domain<\/span> <span class=\"crayon-o\">=<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-11\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_sasl_security_options<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">noanonymous<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-12\" class=\"crayon-line\"><span class=\"crayon-v\">broken_sasl_auth_clients<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-13\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_sasl_auth_enable<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-14\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_recipient_restrictions<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-v\">permit_sasl_authenticated<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-v\">permit_mynetworks<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-e\">reject_unauth_destination<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-15\" class=\"crayon-line\"><span class=\"crayon-v\">smtp_tls_security_level<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">may<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-16\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_security_level<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">may<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-17\" class=\"crayon-line\"><span class=\"crayon-v\">smtp_tls_note_starttls_offer<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-18\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_loglevel<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-cn\">1<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-19\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_key_file<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">etc<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">postfix<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">ssl<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">server<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-e\">key<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-20\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_cert_file<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">etc<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">postfix<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">ssl<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">server<\/span><span class=\"crayon-sy\">.<\/span><span class=\"crayon-e\">crt<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-21\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_received_header<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-22\" class=\"crayon-line\"><span class=\"crayon-v\">smtpd_tls_session_cache_timeout<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-cn\">3600s<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2cb553409228-23\" class=\"crayon-line\"><span class=\"crayon-v\">tls_random_source<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-v\">dev<\/span><span class=\"crayon-o\">:<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">dev<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">urandom<\/span>\n<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>Step 6 \u00bb<\/strong> Open <strong>\/etc\/postfix\/master.cf<\/strong> file, add the below lines after \u201c<strong>smtp inet n \u2013 n \u2013 \u2013 smtpd<\/strong>\u201d line.<\/p>\n<div id=\"crayon-552f205ddd2e3948806719\" class=\"crayon-syntax crayon-theme-cg-cookie crayon-font-monospace crayon-os-pc print-yes notranslate\" data-settings=\" no-popup minimize scroll-always\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<\/div>\n<div class=\"crayon-plain-wrap\">\n<\/div>\n<div class=\"crayon-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"crayon-row\">\n<td class=\"crayon-nums \" data-settings=\"hide\">\n<div class=\"crayon-nums-content\">\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-1\">1\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-2\">2\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-3\">3\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-4\">4\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-5\">5\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-6\">6\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-7\">7\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-8\">8\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-9\">9\n<\/div>\n<div class=\"crayon-num\" data-line=\"crayon-552f205ddd2e3948806719-10\">10\n<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\">\n<div class=\"crayon-pre\">\n<div id=\"crayon-552f205ddd2e3948806719-1\" class=\"crayon-line\"><span class=\"crayon-e\">submission\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-i\">inet<\/span><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-v\">n<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-v\">n<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-v\">smtpd<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-2\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">syslog_name<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">postfix<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">submission<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-3\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">smtpd_sasl_auth_enable<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-4\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">smtpd_recipient_restrictions<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">permit_sasl_authenticated<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-v\">reject<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-5\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">milter_macro_daemon_name<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-e\">ORIGINATING<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-6\" class=\"crayon-line\"><span class=\"crayon-e\">smtps\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-i\">inet<\/span><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-v\">n<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-v\">n<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span class=\"crayon-v\">smtpd<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-7\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">syslog_name<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">postfix<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">smtps<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-8\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">smtpd_sasl_auth_enable<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">yes<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-9\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">smtpd_recipient_restrictions<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">permit_sasl_authenticated<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-v\">reject<\/span>\n<\/div>\n<div id=\"crayon-552f205ddd2e3948806719-10\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">o<\/span> <span class=\"crayon-v\">milter_macro_daemon_name<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">ORIGINATING<\/span>\n<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Now check the configuration using <strong>postfix check<\/strong> command.<br \/>\n<strong>Step 7 \u00bb<\/strong> Now configure Dovecot SASL for SMTP Auth. Open <strong>\/etc\/dovecot\/conf.d\/10-master.conf<\/strong> file, find \u201c<strong># Postfix smtp-auth<\/strong>\u201d line ( line no:95 ) and add the below lines.<br \/>\n<code># Postfix smtp-auth<br \/>\nunix_listener \/var\/spool\/postfix\/private\/auth {<br \/>\nmode = 0660<br \/>\nuser = postfix<br \/>\ngroup = postfix<br \/>\n}<\/code><br \/>\n<strong>Step 8 \u00bb<\/strong> Open <strong>\/etc\/dovecot\/conf.d\/10-auth.conf<\/strong> file, find \u201c<strong>auth_mechanisms = plain<\/strong>\u201d ( Line no: 100 ) and add <strong>login<\/strong> to the value like below.<br \/>\n<code>auth_mechanisms = plain login<\/code><br \/>\n<strong>Step 9 \u00bb<\/strong> Postfix configuration is over. Now restart both postfix and dovecot services and enable auto start.<br \/>\n<code>[root@mail ~]# systemctl restart postfix<br \/>\n[root@mail ~]# systemctl enable postfix<br \/>\n[root@mail ~]# systemctl restart dovecot<br \/>\n[root@mail ~]# systemctl enable dovecot<\/code><br \/>\n<strong>Step 10 \u00bb<\/strong> Add the firewall rules to allow 25, 587 and 465 ports.<br \/>\n<code>[root@mail ~]# firewall-cmd --permanent --add-service=smtp<br \/>\n[root@mail ~]# firewall-cmd --permanent --add-port=587\/tcp<br \/>\n[root@mail ~]# firewall-cmd --permanent --add-port=465\/tcp<br \/>\n[root@mail ~]# firewall-cmd --reload<\/code>Now start testing connectivity for each ports 25,587 and 465 using telnet and make sure you are getting <strong>AUTH PLAIN LOGIN<\/strong> line after issuing <strong>ehlo mail.krizna.com<\/strong>command in telnet.<br \/>\n<code>[root@mail ~]# telnet mail.krizna.com 465<br \/>\nTrying 172.27.0.51...<br \/>\nConnected to mail.krizna.com.<br \/>\nEscape character is '^]'.<br \/>\n220 mail.krizna.com ESMTP Postfix<br \/>\nehlo mail.krizna.com &lt;------- Type this command<br \/>\n250-mail.krizna.com<br \/>\n250-PIPELINING<br \/>\n250-SIZE 10240000<br \/>\n250-VRFY<br \/>\n250-ETRN<br \/>\n250-STARTTLS<br \/>\n250-AUTH PLAIN LOGIN<br \/>\n250-AUTH=PLAIN LOGIN<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-8BITMIME<br \/>\n250 DSN<\/code><\/p>\n<h2>Dovecot configuration<a name=\"dovecot\"><\/a><\/h2>\n<p>Start configuring Dovecot .<br \/>\n<strong>Step 11 \u00bb<\/strong> Open <strong>\/etc\/dovecot\/conf.d\/10-mail.conf<\/strong> file, find <strong>#mail_location =<\/strong> (line no : 30 ) and add the same directory which is given to <strong>home_mailbox<\/strong> in the postfix config file ( Step 5).<br \/>\n<code>mail_location = maildir:~\/mail<\/code><br \/>\n<strong>Step 12 \u00bb<\/strong> Open <strong>\/etc\/dovecot\/conf.d\/20-pop3.conf<\/strong> file, find and uncomment the below line ( line no : 50 ) .<br \/>\n<code>pop3_uidl_format = %08Xu%08Xv<\/code><br \/>\n<strong>Step 13 \u00bb<\/strong> Restart dovecot service.<br \/>\n<code>[root@mail ~]# systemctl restart dovecot<\/code><br \/>\n<strong>Step 14 \u00bb<\/strong> Add firewall rules to allow 110,143,993 and 995.<br \/>\n<code>[root@mail ~]# firewall-cmd --permanent --add-port=110\/tcp<br \/>\n[root@mail ~]# firewall-cmd --permanent --add-service=pop3s<br \/>\n[root@mail ~]# firewall-cmd --permanent --add-port=143\/tcp<br \/>\n[root@mail ~]# firewall-cmd --permanent --add-service=imaps<br \/>\n[root@mail ~]# firewall-cmd --reload<\/code><br \/>\nCheck the connectivity for the ports 110,143,993 and 995 using telnet.<\/p>\n<h2>User creation<a name=\"user\"><\/a><\/h2>\n<p>Now create user for testing .<br \/>\n<strong>Step 15 \u00bb<\/strong> Create user with <strong>\/sbin\/nologin<\/strong> shell to restrict login access.<br \/>\n<code>[root@mail ~]# useradd -m john -s \/sbin\/nologin<br \/>\n[root@mail ~]# passwd john<\/code><br \/>\nMail server is ready now, Configure user in your mail client and test send\/receive.<br \/>\n<a href=\"https:\/\/i0.wp.com\/www.krizna.com\/wp-content\/uploads\/2015\/01\/Setup_mail_server_centos_7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1617\" src=\"https:\/\/i0.wp.com\/1-ps.googleusercontent.com\/hk\/AwAJwg9ecIBNxEHGg0w8SfePD8\/www.krizna.com\/wp-content\/uploads\/2015\/01\/Setup_mail_server_centos_7.png.pagespeed.ce._so1uJb5qKCs4NSN7OOP.png?resize=599%2C345\" alt=\"Setup mail server on centos 7\" width=\"599\" height=\"345\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article helps you to install and configure basic mail server on Centos 7. Here i have used Postfix for SMTP, Dovecot for POP\/IMAP and Dovecot SASL for SMTP AUTH. Before proceeding please make sure you have assigned static IP for the server and have internet connectivity for installing packages. Setup mail server on centos 7 1. Installing packages 2. Postfix configuration 3. Dovecot configuration 4. User creation Installing packages Step 1 \u00bb Assign hostname for the server using the below command. [root@krizna ~]# hostnamectl set-hostname mail.krizna.com Step 2 \u00bb Make a host entry with your IP in \/etc\/hosts file. 172.27.0.51 mail.krizna.com Step 3 \u00bb Now start installing packages. [root@krizna ~]# yum -y install postfix dovecot After package installation continue with postfix configuration. Postfix configuration First create SSL certificate for encryption. Step 4 \u00bb Follow the below steps one by one for creation. [root@mail ~]# mkdir \/etc\/postfix\/ssl [root@mail ~]# cd \/etc\/postfix\/ssl [root@krizna ssl]# openssl genrsa -des3 -out server.key 2048 [root@krizna ssl]# openssl rsa -in server.key -out server.key.insecure [root@krizna ssl]# mv server.key server.key.secure [root@krizna ssl]# mv server.key.insecure server.keyLeave blank for A challenge password [] value in the below step. [root@krizna ssl]# openssl req -new -key server.key -out server.csr [root@krizna ssl]# openssl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-cv","jetpack-related-posts":[{"id":716,"url":"https:\/\/blog.box.kr\/?p=716","url_meta":{"origin":775,"position":0},"title":"CentOS SSH Installation And Configuration","date":"2015-04-15","format":false,"excerpt":"http:\/\/www.cyberciti.biz\/faq\/centos-ssh\/ \u00a0 How do I install and configure ssh server and client under CentOS Linux operating systems? You need to install the following packages (which are installed by default until and unless you removed it or skipped it while installing CentOS) openssh-clients : The OpenSSH client applications openssh-server : The\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":718,"url":"https:\/\/blog.box.kr\/?p=718","url_meta":{"origin":775,"position":1},"title":"How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7","date":"2015-04-15","format":false,"excerpt":"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 \u00a0 How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7 Introduction A LEMP software stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":894,"url":"https:\/\/blog.box.kr\/?p=894","url_meta":{"origin":775,"position":2},"title":"How To Install Cassandra on CentOS 7","date":"2015-06-16","format":false,"excerpt":"Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. NoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL. Pre-Flight Check These instructions are intended\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":766,"url":"https:\/\/blog.box.kr\/?p=766","url_meta":{"origin":775,"position":3},"title":"install bugzilla with nginx on centos7","date":"2015-05-11","format":false,"excerpt":"Set the Hostname Before you begin installing and configuring the components described in this guide, please make sure you\u2019ve followed our instructions for setting your hostname. Issue the following commands to make sure it is set properly: hostname hostname -f The first command should show your short hostname, and the\u2026","rel":"","context":"In &quot;Linux&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":510,"url":"https:\/\/blog.box.kr\/?p=510","url_meta":{"origin":775,"position":4},"title":"[\ud38c]How to enable EPEL repo on CentOS 5 &amp; 6","date":"2014-12-28","format":false,"excerpt":"To enable EPEL (Extra Packages for Enterprise Linux) for CentOS 5 x86 or x64, log in to SSH on your server and execute the following command (dependent on your OS \u2013 unsure of what version of CentOS you are running?): \u00a0CentOS 6.x 32-bit (x86\/i386): rpm -Uvh http:\/\/mirror.overthewire.com.au\/pub\/epel\/6\/i386\/epel-release-6-7.noarch.rpm CentOS 6.x 64-bit\u2026","rel":"","context":"In &quot;Linux&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":826,"url":"https:\/\/blog.box.kr\/?p=826","url_meta":{"origin":775,"position":5},"title":"[scrap]50 UNIX \/ Linux Sysadmin Tutorials","date":"2015-05-20","format":false,"excerpt":"http:\/\/www.thegeekstuff.com\/2010\/12\/50-unix-linux-sysadmin-tutorials\/ \u00a0 Merry Christmas and Happy Holidays to all TGS Readers. To wrap this year, I\u2019ve collected 50 UNIX \/ Linux sysadmin related tutorials that we\u2019ve posted so far. This is lot of reading. Bookmark this article for your future reference and read it whenever you get free time. Disk\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/775"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=775"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/775\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}