{"id":15402,"date":"2024-10-18T06:35:49","date_gmt":"2024-10-18T06:35:49","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=15402"},"modified":"2024-10-21T07:17:00","modified_gmt":"2024-10-21T07:17:00","password":"","slug":"how-to-set-up-postfix-as-a-mail-server-on-ubuntu","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/","title":{"rendered":"How to Set Up Postfix as a Mail Server on Ubuntu"},"content":{"rendered":"\n<p>Postfix is a popular, secure, and easy-to-configure open-source mail transfer agent (MTA) used to route and deliver emails. If you&#8217;re looking to set up a mail server on Ubuntu using Postfix, this guide will walk you through the process.<\/p>\n\n\n\n<p>Managing and maintaining your own mail server can be complex and time-intensive. For many users, it&#8217;s more practical to use a paid email service instead. If you&#8217;re thinking about running your own mail server, we recommend reviewing <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/why-you-may-not-want-to-run-your-own-mail-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">this article<\/a><\/strong> on the potential drawbacks of doing so.<\/p>\n\n\n\n<p>However if you are sure you want to set up your own mail server, you may proceed with the article.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Prerequisites:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running instance of <strong>Ubuntu<\/strong> server (we will use ubuntu 22.04)<\/li>\n\n\n\n<li><strong>sudo<\/strong> or <strong>root<\/strong> access to the server.<\/li>\n\n\n\n<li>A <strong>domain name<\/strong> configured to point to the server. (We will use <strong>beadwork.co.ke<\/strong>)<\/li>\n\n\n\n<li>Ensure that <strong>port 25 (SMTP)<\/strong> is open for outgoing and incoming mail traffic.<\/li>\n<\/ul>\n\n\n\n<p>You could check these steps on <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/first-server-setup-with-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">First Server Setup with Ubuntu<\/a><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Update Your Server<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Before setting up Postfix, it is crucial to update your server with the latest security patches and software packages.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo apt update &amp;&amp; sudo apt upgrade -y<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Install Postfix<\/strong><\/h3>\n\n\n\n<p>Postfix is included in the Ubuntu package repositories, so it can be installed easily with the <code>apt<\/code> package manager. We recommend that you add the <strong>DEBIAN_PRIORITY=low<\/strong> variable to the command so that it can promt you to add some additional configurations<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo DEBIAN_PRIORITY=low apt install postfix<\/strong><\/code><\/pre>\n\n\n\n<p>This installation process will open a series of interactive prompts. For the purposes of this tutorial, use the following information to fill in your prompts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>General type of mail configuration<\/strong>: Select <strong>Internet Site<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"566\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png\" alt=\"\" class=\"wp-image-15494\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png 876w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413-300x194.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413-768x496.png 768w\" sizes=\"auto, (max-width: 876px) 100vw, 876px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>System mail name<\/strong>: This is the base domain used to create valid email addresses when only the account portion of the address is provided. For example, if your server\u2019s hostname is <code>srv.beadwork.co.ke<\/code>, you will likely want to set the system mail name to <code>beadwork.co.ke<\/code>. This way, with the username <code>tke<\/code>, Postfix will use the email address <code>tke@beadwork.co.ke<\/code><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"201\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-403.png\" alt=\"\" class=\"wp-image-15439\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-403.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-403-300x59.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-403-768x151.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Root and postmaster mail recipient<\/strong>: This is the Linux account that will receive mail addressed to <code>root@<\/code> and <code>postmaster@<\/code>. Use your primary account for this. In this case, it would be <code>i@tke.co.ke<\/code><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"282\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395-1024x282.png\" alt=\"\" class=\"wp-image-15428\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395-1024x282.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395-300x83.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395-768x212.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395-1536x423.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-395.png 1583w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Other destinations to accept mail for<\/strong>: This defines the domains for which this Postfix instance will accept mail. If you need to add other domains that this server will handle, do so here. Otherwise, the default settings will suffice.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"189\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414-1024x189.png\" alt=\"\" class=\"wp-image-15496\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414-1024x189.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414-300x55.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414-768x142.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414-1536x284.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-414.png 1860w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Force synchronous updates on mail queue?<\/strong>: Since you are likely using a journaled filesystem, accept\u00a0<strong>No<\/strong>\u00a0here.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"124\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415-1024x124.png\" alt=\"\" class=\"wp-image-15498\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415-1024x124.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415-300x36.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415-768x93.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415-1536x186.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-415.png 1893w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Local networks<\/strong>: This is a list of networks for which your mail server is set to relay messages. The default settings will work in most cases. If you modify it, ensure you restrict the network range appropriately<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"183\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398-1024x183.png\" alt=\"\" class=\"wp-image-15432\" style=\"width:840px;height:auto\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398-1024x183.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398-300x54.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398-768x137.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398-1536x274.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-398.png 1884w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Mailbox size limit<\/strong>: This setting limits the size of incoming messages. Set it to <strong>0<\/strong> to disable any size restrictions.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"188\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399-1024x188.png\" alt=\"\" class=\"wp-image-15433\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399-1024x188.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399-300x55.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399-768x141.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399-1536x282.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-399.png 1867w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Local address extension character<\/strong>: This character separates the main address from an extension, used to create dynamic aliases. The default, <code>+<\/code>, will work for this guide.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-400-1024x357.png\" alt=\"\" class=\"wp-image-15434\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-400-1024x357.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-400-300x105.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-400-768x268.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-400.png 1154w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Internet protocols to use<\/strong>: Choose whether to restrict the IP version that Postfix supports. I will go with  <strong>ipv4<\/strong>.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"286\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401-1024x286.png\" alt=\"\" class=\"wp-image-15435\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401-1024x286.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401-300x84.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401-768x215.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401-1536x429.png 1536w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-401.png 1768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you need to change the above setting that you put during installation, you can do so by running the command below<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo dpkg-reconfigure postfix<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Configure Postfix<\/strong><\/h3>\n\n\n\n<p>After installation, you may need to adjust the Postfix configuration for your specific mail server and to add what was not prompted during installation. <\/p>\n\n\n\n<p>Postfix stores its configuration in the <code>\/etc\/postfix\/main.cf<\/code> file.<\/p>\n\n\n\n<p><strong>Mailbox settings<\/strong>: <\/p>\n\n\n\n<p>Configure where email will be stored. Use Maildir format (which stores each email as a file) for better compatibility:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo postconf -e 'home_mailbox= Maildir\/'<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"69\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-416.png\" alt=\"\" class=\"wp-image-15500\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-416.png 683w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-416-300x30.png 300w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/figure>\n\n\n\n<p>Next, define the location of the <code>virtual_alias_maps<\/code> table, which maps email addresses to Linux system accounts. Run this command to set the table location to a hash database file at<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo postconf -e 'virtual_alias_maps=hash:\/etc\/postfix\/virtual'<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"53\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-417.png\" alt=\"\" class=\"wp-image-15502\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-417.png 851w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-417-300x19.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-417-768x48.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<p>Now that you\u2019ve defined the location of the virtual maps file in the <code>main.cf<\/code> file, create the file and start mapping email accounts to Linux system accounts. Open the file in a text editor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo vim \/etc\/postfix\/virtual<\/strong><\/code><\/pre>\n\n\n\n<p>List any email addresses you wish to accept mail for, followed by a whitespace and the Linux user who will receive the mail.<\/p>\n\n\n\n<p>For example, to accept mail at <code>sales@beadwork.co.ke<\/code> and <code>info@beadwork.co.ke<\/code> and deliver it to the <code>tke<\/code> user, you could configure the file as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sales@beadwork.co.ke tke\ninfo@beadwork.co.ke tke<\/strong><\/code><\/pre>\n\n\n\n<p>After mapping all addresses, save and close the file (with <strong>vim<\/strong>, press <code>wq<\/code>, then press <code>ENTER<\/code>).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"192\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-418.png\" alt=\"\" class=\"wp-image-15503\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-418.png 551w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-418-300x105.png 300w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/figure>\n\n\n\n<p>To apply the changes, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo postmap \/etc\/postfix\/virtual<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"859\" height=\"57\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-419.png\" alt=\"\" class=\"wp-image-15504\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-419.png 859w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-419-300x20.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-419-768x51.png 768w\" sizes=\"auto, (max-width: 859px) 100vw, 859px\" \/><\/figure>\n\n\n\n<p>Restart the Postfix service to apply your changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo systemctl restart postfix<\/strong><\/code><\/pre>\n\n\n\n<p>Since UFW blocks external connections by default, you need to add a rule to allow Postfix connections:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo ufw allow Postfix<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"681\" height=\"105\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-420.png\" alt=\"\" class=\"wp-image-15505\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-420.png 681w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-420-300x46.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/figure>\n\n\n\n<p>At this point, Postfix is ready to accept external connections, but you\u2019ll need a mail client to interact with the mail being delivered to your server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4 \u2014 Installing the Mail Client and Initializing the Maildir Structure<\/strong><\/h3>\n\n\n\n<p>To interact with mail, install the <code>s-nail<\/code> package, a feature-rich email client that correctly handles the Maildir format.<\/p>\n\n\n\n<p>First, ensure that the <code>MAIL<\/code> environment variable is set correctly. This will allow <code>s-nail<\/code> to find the mail for your user. Set the variable in the <code>\/etc\/bash.bashrc<\/code> file and create a file in <code>\/etc\/profile.d\/<\/code> so it is available to all users:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>echo 'export MAIL=~\/Maildir' | sudo tee -a \/etc\/bash.bashrc | sudo tee -a \/etc\/profile.d\/mail.sh<\/strong><\/code><\/pre>\n\n\n\n<p>To read the variable into your current session, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>source \/etc\/profile.d\/mail.sh<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"78\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-422-1024x78.png\" alt=\"\" class=\"wp-image-15507\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-422-1024x78.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-422-300x23.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-422-768x59.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-422.png 1165w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, install <code>s-nail<\/code> using APT:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo apt install s-nail<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"229\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-404-1024x229.png\" alt=\"\" class=\"wp-image-15463\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-404-1024x229.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-404-300x67.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-404-768x172.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-404.png 1134w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Before using the client, adjust a few settings by editing the <code>\/etc\/s-nail.rc<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo vi \/etc\/s-nail.rc<\/strong><\/code><\/pre>\n\n\n\n<p>Add the following options at the bottom of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>set emptystart\nset folder=Maildir\nset record=+sent<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>set emptystart<\/code>: Allows the client to open with an empty inbox.<\/li>\n\n\n\n<li><code>set folder=Maildir<\/code>: Defines the Maildir directory as the folder.<\/li>\n\n\n\n<li><code>set record=+sent<\/code>: Creates a <code>sent<\/code> mbox file for storing sent mail<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"878\" height=\"382\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-406.png\" alt=\"\" class=\"wp-image-15466\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-406.png 878w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-406-300x131.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-406-768x334.png 768w\" sizes=\"auto, (max-width: 878px) 100vw, 878px\" \/><\/figure>\n\n\n\n<p><span style=\"font-size: revert; color: initial;\">Save and close the file.<\/span><\/p>\n\n\n\n<p>To create the Maildir structure, send an initial email to your Linux user. Since the <code>sent<\/code> file is unavailable before Maildir creation, disable writing to it using the <code>-Snorecord<\/code> option. Send the email by piping a string into the <code>s-nail<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>echo 'init' | s-nail -s 'init' -Snorecord tke<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"55\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-423.png\" alt=\"\" class=\"wp-image-15508\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-423.png 697w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-423-300x24.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/figure>\n\n\n\n<p>Afterward, verify the Maildir structure was created:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>ls -R ~\/Maildir<\/strong><\/code><\/pre>\n\n\n\n<p>You should see directories for <code>cur<\/code>, <code>new<\/code>, and <code>tmp<\/code> under <code>~\/Maildir<\/code>, with a message file in the <code>~\/Maildir\/new<\/code> directory.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"282\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-407.png\" alt=\"\" class=\"wp-image-15467\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-407.png 915w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-407-300x92.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-407-768x237.png 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5 \u2014 Testing the Mail Client<\/strong><\/h3>\n\n\n\n<p>Now, test the mail client by opening <code>s-nail<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>s-nail<\/strong><\/code><\/pre>\n\n\n\n<p>You will see the <code>init<\/code> message in the inbox. Press <code>ENTER<\/code> to view it, and <code>h<\/code> followed by <code>ENTER<\/code> to go back to the message list. Press <code>d<\/code> and <code>ENTER<\/code> to delete the message.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"811\" height=\"314\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-425.png\" alt=\"\" class=\"wp-image-15510\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-425.png 811w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-425-300x116.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-425-768x297.png 768w\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" \/><\/figure>\n\n\n\n<p>To test sending mail to an external address, create a test message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>vi ~\/test_message<\/strong><\/code><\/pre>\n\n\n\n<p>Enter some text, save, and close the file.<\/p>\n\n\n\n<p>Send the message using the <code>s-nail<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>cat ~\/test_message | s-nail -s 'Test email subject line' -r contact@beadwork.co.ke tke@beadwork.co.ke\n<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"73\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-426-1024x73.png\" alt=\"\" class=\"wp-image-15511\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-426-1024x73.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-426-300x21.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-426-768x55.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-426.png 1039w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Check your external email inbox for the test message.<\/p>\n\n\n\n<p>Finally, to view sent messages, open <code>s-nail<\/code> and type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>file +sent<\/strong><\/code><\/pre>\n\n\n\n<p>You\u2019ve successfully configured Postfix on your server. Managing email servers can be challenging, but this setup provides the basic functionality to get started with sending and receiving emails.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Postfix is a popular, secure, and easy-to-configure open-source mail transfer agent (MTA) used to route and deliver emails. If you&#8217;re looking to set up a mail server on Ubuntu using Postfix, this guide will walk you through the process. Managing and maintaining your own mail server can be complex and time-intensive. For many users, it&#8217;s [&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-15402","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-06","word_count":1272,"total_views":"0","reactions":{"happy":"25","normal":"0","sad":"0"},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Business Email","term_url":"https:\/\/truehost.com\/support\/docs-category\/business-email\/"},{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Emails","term_url":"https:\/\/truehost.com\/support\/docs-category\/emails\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Set Up Postfix as a Mail Server on Ubuntu -<\/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:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up Postfix as a Mail Server on Ubuntu -\" \/>\n<meta property=\"og:description\" content=\"Postfix is a popular, secure, and easy-to-configure open-source mail transfer agent (MTA) used to route and deliver emails. If you&#8217;re looking to set up a mail server on Ubuntu using Postfix, this guide will walk you through the process. Managing and maintaining your own mail server can be complex and time-intensive. For many users, it&#8217;s [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-21T07:17:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/\",\"name\":\"How to Set Up Postfix as a Mail Server on Ubuntu -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-413.png\",\"datePublished\":\"2024-10-18T06:35:49+00:00\",\"dateModified\":\"2024-10-21T07:17:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-413.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-413.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up Postfix as a Mail Server on Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/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:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up Postfix as a Mail Server on Ubuntu -","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:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up Postfix as a Mail Server on Ubuntu -","og_description":"Postfix is a popular, secure, and easy-to-configure open-source mail transfer agent (MTA) used to route and deliver emails. If you&#8217;re looking to set up a mail server on Ubuntu using Postfix, this guide will walk you through the process. Managing and maintaining your own mail server can be complex and time-intensive. For many users, it&#8217;s [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/","article_modified_time":"2024-10-21T07:17:00+00:00","og_image":[{"url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/","name":"How to Set Up Postfix as a Mail Server on Ubuntu -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png","datePublished":"2024-10-18T06:35:49+00:00","dateModified":"2024-10-21T07:17:00+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-413.png"},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-postfix-as-a-mail-server-on-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Set Up Postfix as a Mail Server on Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/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:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/15402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=15402"}],"version-history":[{"count":26,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/15402\/revisions"}],"predecessor-version":[{"id":15512,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/15402\/revisions\/15512"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=15402"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=15402"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=15402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}