{"id":15404,"date":"2024-10-18T06:36:26","date_gmt":"2024-10-18T06:36:26","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=15404"},"modified":"2024-10-28T10:28:57","modified_gmt":"2024-10-28T10:28:57","password":"","slug":"how-to-configure-smtp-relays-on-a-linux-server","status":"publish","type":"docs","link":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/","title":{"rendered":"How to Configure SMTP Relays on a Linux Server"},"content":{"rendered":"\n<p>Setting up an SMTP relay on a Linux server can help manage outgoing emails more effectively and can prevent your mail server from being flagged for spam. Below is a step-by-step guide for configuring an SMTP relay with <code>Postfix<\/code>, a commonly used mail transfer agent on Linux.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Linux server with root access.<\/li>\n\n\n\n<li><code>Postfix<\/code> installed (you can install it using <code>apt install postfix<\/code> on Debian\/Ubuntu or <code>yum install postfix<\/code> on RHEL\/CentOS).<\/li>\n\n\n\n<li>An SMTP relay service provider such as SendGrid, Mailgun, Amazon SES, or an existing external SMTP server.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 1: Install Postfix<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install postfix using <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a><\/strong> if you are on Ubuntu and with <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-configure-a-mail-server-with-dovecot-and-postfix\/\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a><\/strong> if you are on Almalinux.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 2: Configure Postfix for SMTP Relay<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Edit the Postfix configuration file located at <code>\/etc\/postfix\/main.cf<\/code>:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo vi \/etc\/postfix\/main.cf<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Look for the <strong>relayhost<\/strong>, settings usually looking as below or add them if they are missing.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>relayhost = <\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You will then modify the setting and add your SMTP relay hostname and port number. E.g, If I want to relay my emails through a server with hostname as <strong>relayhost = [smtp.relayhost.com]:587<\/strong> on port 587, I will set my relay host as below<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>relayhost = smtp.truehost.com:587<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"207\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png\" alt=\"\" class=\"wp-image-15896\" srcset=\"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png 679w, https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568-300x91.png 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you use a firewall, you may need to allow the port that you used in your relayhost line through the firewall. <\/li>\n\n\n\n<li>If you use firewalld, you can use the command below, replacing 1234 with the port that you want to allow<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo firewall-cmd --permanent --add-port=1234\/tcp<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"744\" height=\"155\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-569.png\" alt=\"\" class=\"wp-image-15903\" srcset=\"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-569.png 744w, https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-569-300x63.png 300w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/figure>\n\n\n\n<p><strong>Step 5: Restart Postfix<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After making these changes, restart the Postfix service for the changes to take effect:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo systemctl restart postfix<\/strong><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 6: Test the Configuration<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To verify that the relay is working, you can send a test email. Use the <code>mail<\/code> command or any other mail client.<\/li>\n\n\n\n<li>Replace <code>recipient@example.com<\/code> with an actual email address to test.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>echo \"This is a test email\" | mail -s \"Test Email\" recipient@example.com<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To view the logs and troubleshoot if the email was not sent, check the Postfix log file:<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Additional Configuration Tips<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Setting a Default Sender Domain<\/strong>: You can specify the default sender domain by setting <code>myorigin<\/code> in <code>\/etc\/postfix\/main.cf<\/code>.<\/li>\n\n\n\n<li><strong>Rate Limiting<\/strong>: To avoid getting flagged by your relay provider, you can limit the number of outgoing emails in Postfix with additional configuration settings (useful for high-volume email applications).<\/li>\n\n\n\n<li><strong>Firewall Rules<\/strong>: Ensure that your server\u2019s firewall allows outgoing connections to the relay\u2019s SMTP port (e.g., port 587 or 465).<\/li>\n<\/ul>\n\n\n\n<p>You should now have a working SMTP relay configured on your Linux server using Postfix! This setup will relay all outgoing emails through the specified SMTP server, providing more reliable delivery and reducing the chances of your emails being marked as spam.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up an SMTP relay on a Linux server can help manage outgoing emails more effectively and can prevent your mail server from being flagged for spam. Below is a step-by-step guide for configuring an SMTP relay with Postfix, a commonly used mail transfer agent on Linux. Prerequisites Step 1: Install Postfix Step 2: Configure [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1881,1820,1824,1827,1879,2128],"doc_tag":[],"class_list":["post-15404","docs","type-docs","status-publish","hentry","doc_category-business-email","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-emails","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":450,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/www.truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Business Email","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/business-email\/"},{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Emails","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/emails\/"},{"term_name":"Servers","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/www.truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Configure SMTP Relays on a Linux Server -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Configure SMTP Relays on a Linux Server -\" \/>\n<meta property=\"og:description\" content=\"Setting up an SMTP relay on a Linux server can help manage outgoing emails more effectively and can prevent your mail server from being flagged for spam. Below is a step-by-step guide for configuring an SMTP relay with Postfix, a commonly used mail transfer agent on Linux. Prerequisites Step 1: Install Postfix Step 2: Configure [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-28T10:28:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/\",\"name\":\"How to Configure SMTP Relays on a Linux Server -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-568.png\",\"datePublished\":\"2024-10-18T06:36:26+00:00\",\"dateModified\":\"2024-10-28T10:28:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-568.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-568.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-configure-smtp-relays-on-a-linux-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Configure SMTP Relays on a Linux Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Configure SMTP Relays on a Linux Server -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/","og_locale":"en_US","og_type":"article","og_title":"How to Configure SMTP Relays on a Linux Server -","og_description":"Setting up an SMTP relay on a Linux server can help manage outgoing emails more effectively and can prevent your mail server from being flagged for spam. Below is a step-by-step guide for configuring an SMTP relay with Postfix, a commonly used mail transfer agent on Linux. Prerequisites Step 1: Install Postfix Step 2: Configure [&hellip;]","og_url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/","article_modified_time":"2024-10-28T10:28:57+00:00","og_image":[{"url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/","url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/","name":"How to Configure SMTP Relays on a Linux Server -","isPartOf":{"@id":"https:\/\/www.truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/#primaryimage"},"image":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png","datePublished":"2024-10-18T06:36:26+00:00","dateModified":"2024-10-28T10:28:57+00:00","breadcrumb":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-568.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-configure-smtp-relays-on-a-linux-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Configure SMTP Relays on a Linux Server"}]},{"@type":"WebSite","@id":"https:\/\/www.truehost.com\/support\/#website","url":"https:\/\/www.truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/www.truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/www.truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/www.truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/www.truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/docs\/15404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/comments?post=15404"}],"version-history":[{"count":6,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/docs\/15404\/revisions"}],"predecessor-version":[{"id":15904,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/docs\/15404\/revisions\/15904"}],"wp:attachment":[{"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/media?parent=15404"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=15404"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=15404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}