{"id":227,"date":"2023-06-13T06:28:26","date_gmt":"2023-06-13T13:28:26","guid":{"rendered":"https:\/\/www.cmsws.com\/blog\/?p=227"},"modified":"2023-06-13T06:29:43","modified_gmt":"2023-06-13T13:29:43","slug":"configure-postfix-to-relay-sub-domains","status":"publish","type":"post","link":"https:\/\/www.cmsws.com\/blog\/configure-postfix-to-relay-sub-domains\/","title":{"rendered":"Configure Postfix to relay sub-domains"},"content":{"rendered":"\n<p>I found myself in need to having Postfix relay or forward an entire sub-domain to a remote server.  My setup includes a number of test servers running my development installs of the <a href=\"http:\/\/freeside.biz\" title=\"Freeside Billing system\">Freeside Billing system<\/a>.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.cmsws.com\/blog\/configure-postfix-to-relay-sub-domains\/#Enable_transport_in_Postfix\" >Enable transport in Postfix<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.cmsws.com\/blog\/configure-postfix-to-relay-sub-domains\/#Create_the_transport_table\" >Create the transport table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.cmsws.com\/blog\/configure-postfix-to-relay-sub-domains\/#Hash_that_file%E2%80%A6\" >Hash that file&#8230;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.cmsws.com\/blog\/configure-postfix-to-relay-sub-domains\/#Restart_Postfix\" >Restart Postfix<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>The setups need to be able to both send and receive email.  Sending is for system email delivery.  Receiving is mainly for the built-in <a href=\"https:\/\/bestpractical.com\/\" title=\"Request Tracker\">Request Tracker<\/a> ticketing system.  I have <a href=\"https:\/\/www.cmsws.com\/blog\/how-to-set-up-a-mail-server-with-postfix-dovecot-and-postfixadmin-on-debian-11\/\" title=\"Set Up a Mail Server\">installed Postfix<\/a> on a separate web server I am planning on replacing my primary production server.  <\/p>\n\n\n\n<p>Let&#8217;s get started&#8230;<\/p>\n\n\n\n<p>Postfix is an extremely complex and customizable MTA.  One of its many function is to provide &#8220;transport&#8221; for entire domains or individual mailboxes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Enable_transport_in_Postfix\"><\/span>Enable transport in Postfix<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Edit: \/etc\/postfix\/main.cf    Add the following.<\/p>\n\n\n\n<pre id=\"block-53da59b0-470e-4d24-84d4-27c4d9eb659c\" class=\"wp-block-code\"><code>transport_maps = hash:\/etc\/postfix\/transport<\/code><\/pre>\n\n\n\n<p>For each domain or sub-domain you want to relay add the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>relay_domain = domain.com sub.domain.com sub.sub.domain.com<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_the_transport_table\"><\/span>Create the transport table<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Edit\/create \/etc\/postfix\/transport   Add the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>domain.com             smtp:127.0.0.1:10025\nsub.domain.com         smtp:10.20.20.20:25\nsub.sub.domain.com     smtp:192.168.0.101:10025<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hash_that_file%E2%80%A6\"><\/span>Hash that file&#8230;<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Run the following command to create a has table that Postfix can read.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo postmap \/etc\/postfix\/transport<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Restart_Postfix\"><\/span>Restart Postfix<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl restart postfix<\/code><\/pre>\n\n\n\n<p>You should be able to tail your maillog file and see mail being relayed.<\/p>\n\n\n\n<p>Be sure to read the <a href=\"http:\/\/www.postfix.org\/transport.5.html\" title=\"main page for transport\">main page for transport<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found myself in need to having Postfix relay or forward an entire sub-domain to a remote server. My setup includes a number of test servers running my development installs of the Freeside Billing system. The setups need to be able to both send and receive email. Sending is for system email delivery. Receiving is mainly for the built-in Request [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":229,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,22,25],"tags":[16,41,38],"class_list":["post-227","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-email","category-freeside","category-linux","tag-freeside","tag-postfix","tag-request-tracker"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":2,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/posts\/227\/revisions\/232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/media\/229"}],"wp:attachment":[{"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsws.com\/blog\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}