{"id":2050,"date":"2021-04-26T22:15:13","date_gmt":"2021-04-26T22:15:13","guid":{"rendered":"https:\/\/dft.wiki\/?p=2050"},"modified":"2026-04-21T13:34:16","modified_gmt":"2026-04-21T17:34:16","slug":"e-mail-backup-server-with-postfix-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=2050","title":{"rendered":"E-mail Backup Server with Postfix on Ubuntu"},"content":{"rendered":"<p>Add another MX record on the domain DNS with a priority different (e.g. <strong>10<\/strong>) from the main server (<strong>zero<\/strong>).<\/p>\n<pre>0     mx.example.com\r\n10    mx2.example.com<\/pre>\n<p>Set up the server and install Postfix.<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo apt install postfix -y<\/pre>\n<p>Choose <strong>Internet Site<\/strong>.<\/p>\n<p>Enter the server&#8217;s name <strong>mx2.example.com<\/strong>.<\/p>\n<p>Edit <strong>\/etc\/postfix\/main.cf<\/strong>:<\/p>\n<pre>smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination\r\nrelay_domains = <strong>example.com<\/strong>\r\nmyhostname = <strong>mx2.example.com<\/strong>\r\nmydestination = $myhostname, localhost, localhost.localdomain, <strong>mx2.example.com<\/strong>\r\nmaximal_queue_lifetime = <strong>10d\r\n<\/strong>relay_recipient_maps = hash:\/etc\/postfix\/relay_recipients<\/pre>\n<p>Create or edit <strong>\/etc\/postfix\/relay_recipients<\/strong>\u00a0accordingly:<\/p>\n<pre>userone@example.com OK\r\nusertwo@example.com OK\r\n@example2.com OK<\/pre>\n<p>Create the <strong>relay_recipients.db<\/strong> and restart Postfix&#8217; service.<\/p>\n<pre>sudo postmap \/etc\/postfix\/relay_recipients\r\nsudo systemctl restart postfix<\/pre>\n<p>Optionally add the SSL\/TLS certificate at <strong>\/etc\/postfix\/main.cf<\/strong>:<\/p>\n<pre>smtpd_tls_cert_file=\/etc\/ssl\/<strong>mx2.example.com<\/strong>\/pubcert.pem\r\nsmtpd_tls_key_file=\/etc\/ssl\/<strong>mx2.example.com<\/strong>\/privkey.pem\r\nsmtpd_tls_security_level = <strong>may<\/strong> <span style=\"color: #ff0000;\"># or use encrypt to enforce<\/span> \r\nsmtpd_tls_protocols = !SSLv2, !SSLv3 !TLSv1\r\nsmtpd_tls_loglevel = 1<\/pre>\n<p>Restart Postfix.<\/p>\n<pre>sudo systemctl restart postfix<\/pre>\n<p>On the <strong>PRIMARY SERVER<\/strong> add the IP of the secondary on the file <strong>\/etc\/postfix\/main.cf<\/strong>:<\/p>\n<pre>smtp_fallback_relay = [<strong><span style=\"color: #ff0000;\">200.200.200.200<\/span><\/strong>]:25<\/pre>\n<p>On the <strong>SECONDARY SERVER<\/strong> add the IP of the primary on the <strong>\/etc\/postfix\/main.cf<\/strong>:<\/p>\n<pre>mynetworks = 127.0.0.0\/8 [::ffff:127.0.0.0]\/104 [::1]\/128 <strong><span style=\"color: #ff0000;\">100.100.100.100<\/span><\/strong><\/pre>\n<p>Restart both services:<\/p>\n<pre>sudo systemctl restart postfix<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Add another MX record on the domain DNS with a priority different (e.g. 10) from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-2050","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2050"}],"version-history":[{"count":3,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2050\/revisions"}],"predecessor-version":[{"id":5485,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2050\/revisions\/5485"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}