{"id":396,"date":"2018-07-13T06:55:35","date_gmt":"2018-07-13T06:55:35","guid":{"rendered":"http:\/\/linuxresellerwebhosting.in\/blog\/?p=396"},"modified":"2018-08-28T14:03:45","modified_gmt":"2018-08-28T14:03:45","slug":"easy-steps-to-configure-postfix-mail-server-on-cent-os","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/easy-steps-to-configure-postfix-mail-server-on-cent-os\/","title":{"rendered":"Easy Steps to Configure POSTFIX Mail Server on Cent OS"},"content":{"rendered":"<p>Hi All,<\/p>\n<p>Today we are going to see about how to configure simple POSTFIX mail server on Cent OS.<\/p>\n<h3>Installing Postfix<\/h3>\n<p>Login to your server and run the following command to update the repository and packages available in your system.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">yum -y update<\/code><\/pre>\n<p>Now update the hostname of your system to the FQDN you want to use with your mail server. Run the following command to change your hostname.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\"><span class=\"token function\">hostname<\/span> mail.yourdomain.com<\/code><\/pre>\n<p>Now add the hostname entry in the host files of your system. Edit\u00a0<code>\/etc\/hosts<\/code>\u00a0files using your favorite editor. For example if your are using\u00a0<code>nano<\/code>\u00a0then you will need to run the following command.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\"><span class=\"token function\">nano<\/span> \/etc\/hosts<\/code><\/pre>\n<p>You will see two lines of entries in there, append your server IP address followed by hostname at the end of the file. It should look like the one shown below.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\r\n::1       localhost localhost.localdomain localhost6 localhost6.localdomain6\r\n104.36.18.239 mail.yourdomain.com<\/code><\/pre>\n<p>Now we can install Postfix, enter the following command to do so.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">yum -y <span class=\"token function\">install<\/span> postfix<\/code><\/pre>\n<p>Before configuring postfix we will need to configure SSL which will be used to encrypt and secure the emails.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\"> <span class=\"token function\">mkdir<\/span> \/etc\/postfix\/ssl\r\n<span class=\"token function\">cd<\/span> \/etc\/postfix\/ssl<\/code><\/pre>\n<p>Now we will have to create SSL certificates. If you do not have\u00a0<code>openssl<\/code>\u00a0installed you can install it using the following command.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">yum -y <span class=\"token function\">install<\/span> openssl<\/code><\/pre>\n<p>Now run the following command to create certificate and key files.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">openssl req -x509 -nodes -newkey rsa:2048 -keyout server.key -out server.crt -nodes -days 365<\/code><\/pre>\n<p>After that you have to generate CSR by providing some information and This will generate the key file and certificates and will save then in\u00a0<code>\/etc\/postfix\/ssl<\/code>\u00a0directory.<\/p>\n<p>Now edit postfix configuration file which can be found at\u00a0<code>\/etc\/postfix\/main.cf<\/code>, with your favorite editor.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\"><span class=\"token function\">vi<\/span> \/etc\/postfix\/main.cf<\/code><\/pre>\n<p>and append these lines at the end of the file.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">myhostname <span class=\"token operator\">=<\/span> mail.yourdomain.com\r\nmydomain <span class=\"token operator\">=<\/span> yourdomain.com\r\nmyorigin <span class=\"token operator\">=<\/span> <span class=\"token variable\">$mydomain<\/span>\r\nhome_mailbox <span class=\"token operator\">=<\/span> mail\/\r\nmynetworks <span class=\"token operator\">=<\/span> 127.0.0.0\/8\r\ninet_interfaces <span class=\"token operator\">=<\/span> all\r\ninet_protocols <span class=\"token operator\">=<\/span> all\r\ninet_interfaces <span class=\"token operator\">=<\/span> localhost\r\nmydestination <span class=\"token operator\">=<\/span> <span class=\"token variable\">$myhostname<\/span>, localhost.<span class=\"token variable\">$mydomain<\/span>, localhost, <span class=\"token variable\">$mydomain<\/span>\r\nsmtpd_sasl_type <span class=\"token operator\">=<\/span> dovecot\r\nsmtpd_sasl_path <span class=\"token operator\">=<\/span> private\/auth\r\nsmtpd_sasl_local_domain <span class=\"token operator\">=<\/span>\r\nsmtpd_sasl_security_options <span class=\"token operator\">=<\/span> noanonymous\r\nbroken_sasl_auth_clients <span class=\"token operator\">=<\/span> <span class=\"token function\">yes<\/span>\r\nsmtpd_sasl_auth_enable <span class=\"token operator\">=<\/span> <span class=\"token function\">yes<\/span>\r\nsmtpd_recipient_restrictions <span class=\"token operator\">=<\/span> permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination\r\nsmtp_tls_security_level <span class=\"token operator\">=<\/span> may\r\nsmtpd_tls_security_level <span class=\"token operator\">=<\/span> may\r\nsmtp_tls_note_starttls_offer <span class=\"token operator\">=<\/span> <span class=\"token function\">yes<\/span>\r\nsmtpd_tls_loglevel <span class=\"token operator\">=<\/span> 1\r\nsmtpd_tls_key_file <span class=\"token operator\">=<\/span> \/etc\/postfix\/ssl\/server.key\r\nsmtpd_tls_cert_file <span class=\"token operator\">=<\/span> \/etc\/postfix\/ssl\/server.crt\r\nsmtpd_tls_received_header <span class=\"token operator\">=<\/span> <span class=\"token function\">yes<\/span>\r\nsmtpd_tls_session_cache_timeout <span class=\"token operator\">=<\/span> 3600s\r\ntls_random_source <span class=\"token operator\">=<\/span> dev:\/dev\/urandom\r\n<\/code><\/pre>\n<p>Now open another configuration file\u00a0<code>\/etc\/postfix\/master.cf<\/code><\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\"> <span class=\"token function\">nano<\/span>  \/etc\/postfix\/master.cf<\/code><\/pre>\n<p>and find the following lines in the configuration file.<\/p>\n<pre class=\" language-bash\"><code class=\" language-bash\">    <span class=\"token comment\" spellcheck=\"true\"># service type  private unpriv  chroot  wakeup  maxproc command + args<\/span>\r\n    <span class=\"token comment\" spellcheck=\"true\">#               (yes)   (yes)   (yes)   (never) (100)<\/span>\r\n    <span class=\"token comment\" spellcheck=\"true\"># ==========================================================================<\/span>\r\n    smtp      inet  n       -       n       -       -       smtpd\r\n<\/code><\/pre>\n<p>Now add the following lines at just below these lines.<\/p>\n<pre class=\"language-bash\"><code class=\" language-bash\">    submission     inet  n       -       n       -       -       smtpd\r\n      -o syslog_name<span class=\"token operator\">=<\/span>postfix\/submission\r\n      -o smtpd_sasl_auth_enable<span class=\"token operator\">=<\/span>yes\r\n      -o smtpd_recipient_restrictions<span class=\"token operator\">=<\/span>permit_sasl_authenticated,reject\r\n      -o milter_macro_daemon_name<span class=\"token operator\">=<\/span>ORIGINATING\r\n    smtps     inet  n       -       n       -       -       smtpd\r\n      -o syslog_name<span class=\"token operator\">=<\/span>postfix\/smtps\r\n      -o smtpd_sasl_auth_enable<span class=\"token operator\">=<\/span>yes\r\n      -o smtpd_recipient_restrictions<span class=\"token operator\">=<\/span>permit_sasl_authenticated,reject\r\n      -o milter_macro_daemon_name<span class=\"token operator\">=<\/span>ORIGINATING<\/code><\/pre>\n<p>Now You have successfully installed and configured POSTFIX in your linux machine.<\/p>\n<p>Next we will how to install dovecot on our upcoming tutorial. Thanks for reading our tutorial \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi All, Today we are going to see about how to configure simple POSTFIX mail server on Cent OS. Installing<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-linux","category-vps"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=396"}],"version-history":[{"count":10,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":433,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/396\/revisions\/433"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}