{"id":1941,"date":"2019-01-05T17:21:20","date_gmt":"2019-01-05T14:21:20","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1941"},"modified":"2024-03-11T22:06:50","modified_gmt":"2024-03-11T19:06:50","slug":"configure-postfix-as-send-only-smtp-server-on-fedora-29","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-postfix-as-send-only-smtp-server-on-fedora-29\/","title":{"rendered":"Configure Postfix as Send-Only SMTP Server on Fedora 29"},"content":{"rendered":"\n<p>In this guide, we are going to learn how to install and configure Postfix as send-only SMTP server on Fedora 29. <a href=\"https:\/\/www.postfix.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Postfix<\/a> is a free and opensource mail transfer agent (MTA) that routes and delivers emails to the systems that are external to it. In this article, we are going to learn how configure Postfix to act a as send-only SMTP server such that it can only send emails rather than receive nor process them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Postfix as Send-Only SMTP Server on Fedora 29<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install Postfix on Fedora 29<\/h3>\n\n\n\n<p>Postfix is available on Fedora default repos. Before you can install it, ensure that you system packages are up-to-date.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf update\ndnf install postfix<\/code><\/pre>\n\n\n\n<p>Once the installation is done, proceed to configure Postfix as send-only SMTP server.<\/p>\n\n\n\n<p>Start and enable Postfix to run on system boot<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl start postfix<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable postfix<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-\u2014-configure-postfix\">Configure Postfix as send-only SMTP server<\/h2>\n\n\n\n<p>In order for Postfix to process and send mails from the server in which it is running, i.e the <code>localhost<\/code>, we need to configure it to listen on the <code>loopback interface, 127.0.0.1<\/code> only. Therefore, open the main configuration file for Postfix, <code>\/etc\/postfix\/main.cf<\/code>, for editing and replace the value of <code>inet_interfaces<\/code> to <code>localhost<\/code> or <code>loopback-only<\/code> if it is not set by default. The <code>inet_interfaces<\/code> is set to <code>localhost<\/code> by default on Fedora 29. If this is not the case for you, make appropriate adjustments.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim&nbsp; \/etc\/postfix\/main.cf<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\n#inet_interfaces = all\n#inet_interfaces = $myhostname\n#inet_interfaces = $myhostname, localhost\n<strong>inet_interfaces = localhost<\/strong>\n\n# Enable IPv4, and IPv6 if supported\ninet_protocols = all\n...\n<\/code><\/pre>\n\n\n\n<p>If you make any changes, be sure to restart Postfix for the changes to take effect.<\/p>\n\n\n\n<p>Before you restart, be sure to check if any errors;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postfix check<\/code><\/pre>\n\n\n\n<p>If all good, restart<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart postfix<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Test the Postfix SMTP server<\/h3>\n\n\n\n<p>To confirm that your local Postfix can actually send mails, you can try to send a test mail. Replace the <code>userid@domain.com<\/code> with your external email ID.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mail -s \"Testing Send-only Postfix SMTP\" <strong>userid@domain.com<\/strong> &lt; \/dev\/null<\/code><\/pre>\n\n\n\n<p>You should be able to receive an empty mail with subject &#8220;Testing Send-only Postfix SMTP&#8221; on your email account.<\/p>\n\n\n\n<p>If you encounter an error, <code>bash: mail: command not found<\/code>, run the command below to install mail command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install mailx<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Forward System Mails<\/h3>\n\n\n\n<p>In order to receive system mails (mails sent to<code> root<\/code> user) on an external mail account, you need to configure system mail forwarding. By default, system-generated mails are forwarded to root user on the local system as defined by the following line on <code>\/etc\/aliases<\/code> configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># Basic system aliases -- these MUST be present.\nmailer-daemon:  postmaster\n<strong>postmaster:     root<\/strong><\/code><\/pre>\n\n\n\n<p>To forward all mails sent to root user, you need to forward them to your external email address. Therefore, open the aliases configuration file and make the changes as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/aliases<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># Basic system aliases -- these MUST be present.\nmailer-daemon:  postmaster\npostmaster:     root\n<strong>root:   user@domain.com<\/strong><\/code><\/pre>\n\n\n\n<p>Be sure to replace <code>user@domain.com<\/code> with your email ID.<\/p>\n\n\n\n<p>In order to rebuild the database for the mail aliases file, <code>\/etc\/aliases<\/code>, run the command <code>newaliases<\/code> every time this file is changed in order for the changes to take effect.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>newaliases<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Verify Mail Forwarding<\/h3>\n\n\n\n<p>Now that the configurations are done, you can test to verify that your send-only SMTP server can send mails. You can use the mail command to do the test as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo \"Testing Mail Forwarding to Postfix SMTP\" | mail -s \"Forward System Mails\" root<\/code><\/pre>\n\n\n\n<p>Similarly, you should be able to receive the mail on your external email account.<\/p>\n\n\n\n<p>You can also check our previous article on <a title=\"How to Install and Setup iRedMail Mail Server on Ubuntu 18.04 LTS\" href=\"https:\/\/kifarunix.com\/how-to-setup-iredmail-mail-server-on-ubuntu-18-04-lts\/\" rel=\"bookmark\">How to Install and Setup iRedMail Mail Server on Ubuntu 18.04 LTS<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn how to install and configure Postfix as send-only SMTP server on Fedora 29. Postfix is a free<\/p>\n","protected":false},"author":1,"featured_media":13773,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,272],"tags":[5708,289,5710,288,5711,5709],"class_list":["post-1941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-email","tag-configure-postfix-as-send-only-smtp-server-on-fedora","tag-fedora-29","tag-install-postfix-on-fedora","tag-postfix","tag-postfix-with-gmail-on-fedora","tag-setup-postfix-on-fedora","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1941"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=1941"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1941\/revisions"}],"predecessor-version":[{"id":21101,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/1941\/revisions\/21101"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/13773"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=1941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=1941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=1941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}