{"id":660,"date":"2025-07-24T04:17:06","date_gmt":"2025-07-24T02:17:06","guid":{"rendered":"https:\/\/raspberrytips.com\/?p=660"},"modified":"2026-04-28T01:24:33","modified_gmt":"2026-04-27T23:24:33","slug":"mail-server-raspberry-pi","status":"publish","type":"post","link":"https:\/\/raspberrytips.com\/mail-server-raspberry-pi\/","title":{"rendered":"How to Host Your Own Email Server on Raspberry\u202fPi"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Setting up your own mail server can be tricky&#8230; I\u2019ve done it a few times, and it\u2019s never as straightforward as it sounds. Whether you&#8217;re aiming for a simple SMTP setup or a full webmail suite, I&#8217;ll break down the key steps to help you get it running smoothly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Postfix is the main service to install on Raspberry Pi to host a mail server. It&#8217;ll send and receive emails.<\/strong> <strong>Then other services can be added, like Dovecot for POP\/IMAP support and Roundcube can be used as webmail.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, I\u2019ll show you how to install each component one step at a time, with tips to avoid common mistakes. By the end, you&#8217;ll have a working mail server you can manage and tweak just like any pro.<\/p>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-content-wrap{padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);background-color:var(--global-palette7, #EDF2F7);box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-contents-title{font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-table-of-content-wrap .kb-table-of-content-list{font-size:var(--global-kb-font-size-sm, 0.9rem);font-weight:regular;font-style:normal;margin-top:var(--global-kb-spacing-sm, 1.5rem);margin-right:0px;margin-bottom:0px;margin-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-basiccircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-basiccircle .kb-table-of-contents-icon-trigger:before, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-arrowcircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-arrowcircle .kb-table-of-contents-icon-trigger:before, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-xclosecircle .kb-table-of-contents-icon-trigger:after, .kb-table-of-content-nav.kb-table-of-content-id19563_c031ec-35 .kb-toggle-icon-style-xclosecircle .kb-table-of-contents-icon-trigger:before{background-color:var(--global-palette7, #EDF2F7);}<\/style>\n\n<p class='ml_begpost' id='ml_begpost_commands'>If you&#8217;re new to Raspberry Pi or Linux, I\u2019ve got something that can help you right away! <br \/><a rel='noopener' href='https:\/\/raspberrytips.com\/downloads\/?source=begpost&#038;lm=4' target='_blank'>Download my free Linux commands cheat sheet<\/a> \u2013 it\u2019s a quick reference guide with all the essential commands you\u2019ll need to get things done on your Raspberry Pi. <a rel='noopener' href='https:\/\/raspberrytips.com\/downloads\/?source=begpost&#038;lm=4' target='_blank'><b>Click here to get it for free!<\/b><\/a><\/p>\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to set up an SMTP server, the requirements are almost zero.<br>A Raspberry Pi and an SMTP server that will serve as a relay is sufficient (Gmail for example).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If you want to follow the tutorial until the end, you will need:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>A Raspberry Pi<\/strong>: Any model should be fine, but I would recommend a <a href=\"https:\/\/raspberrytips.com\/amz\/pi4\" target=\"_blank\" rel=\"noreferrer noopener\">Raspberry Pi 4<\/a> or at least a <a href=\"https:\/\/raspberrytips.com\/amz\/pi3b\" target=\"_blank\" rel=\"noreferrer noopener\">Raspberry Pi 3B+<\/a>.<\/li>\n\n\n\n<li><strong>A micro-SD card or USB key<\/strong>: I tend to use SD cards less and less, and <a rel=\"noreferrer noopener\" href=\"https:\/\/raspberrytips.com\/amz\/usb\" target=\"_blank\">use this USB drive<\/a> from SanDisk instead for all my experiments. But if you want to use an SD card you can, I did a <a rel=\"noreferrer noopener\" href=\"https:\/\/raspberrytips.com\/best-sd-card-raspberry-pi\/\" data-type=\"post\" data-id=\"3947\" target=\"_blank\">benchmark of the most popular SD cards<\/a> here.<\/li>\n\n\n\n<li><strong>A domain name (I will use domain.com in all the steps below, don&#8217;t forget to change it).<\/strong><\/li>\n\n\n\n<li><strong>A static public IP address (or at least one dynamic DNS service, <a href=\"https:\/\/raspberrytips.com\/install-no-ip-raspberry-pi\/\" data-type=\"post\" data-id=\"6277\">like No-Ip<\/a>).<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Also, know that I make this tutorial on Raspberry Pi OS, so I recommend installing Raspberry Pi OS first (Lite will be enough) by <a rel=\"noopener\" data-lasso-id=\"2373\" href=\"https:\/\/raspberrytips.com\/install-raspbian-raspberry-pi\/\" target=\"_blank\">following this tutorial<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I suggest you use SSH to follow this tutorial from your usual computer and copy\/paste commands and configurations (there are a lot of them!). If you need help to <a href=\"https:\/\/raspberrytips.com\/ssh-guide-raspberry-pi\/\" data-type=\"post\" data-id=\"10748\">set up SSH on your Raspberry Pi<\/a>, click on the link to learn everything about this protocol and how to use it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Security Warning<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Creating your secure mail server is not straightforward.<br>It&#8217;s easy to miss the configuration and turn your server into an open SMTP relay for the world, or get spammed over.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So <strong>be sure to follow this tutorial precisely, and then monitor the system logs to make sure that&nbsp;you are the only one doing the actions that occur on your server.<\/strong><br>Setting up additional security features such as a <a href=\"https:\/\/raspberrytips.com\/raspberry-pi-firewall\/\" data-type=\"post\" data-id=\"1341\">firewall<\/a> or <a href=\"https:\/\/raspberrytips.com\/install-fail2ban-raspberry-pi\/\" data-type=\"post\" data-id=\"2458\">fail2ban <\/a>service is also a good idea.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">DNS Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>In the next steps, we will change our domain name DNS settings to use our IP address as the mail server.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">IP Address<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you don&#8217;t have a static public IP address, you will need to use a free dynamic DNS service like <a href=\"https:\/\/raspberrytips.com\/no-ip\" target=\"_blank\" rel=\"noreferrer noopener\">No-IP<\/a> to redirect a domain to your dynamic IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll have to install a tool to regularly give them your current IP address, and they will redirect a domain like myserver.ddns.net to your last known IP address (<a rel=\"noopener\" data-lasso-id=\"2375\" href=\"https:\/\/raspberrytips.com\/install-no-ip-raspberry-pi\/\" target=\"_blank\">more details about this here<\/a>).<br>If you don&#8217;t have a domain name, I think that&nbsp;you can use this alias directly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s not the perfect option for an email server because you&#8217;ll have small downtimes when your IP&nbsp;changes, but if you&#8217;re not too serious about your emails, it should be fine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">DNS Zone Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Now you need to go to your domain name registrar and change these zones to match your current IP address <\/strong>(or your dynamic DNS&nbsp;provider domain name):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MX<\/li>\n\n\n\n<li>pop.domain.com<\/li>\n\n\n\n<li>smtp.domain.com<\/li>\n\n\n\n<li>imap.domain.com<\/li>\n\n\n\n<li>mail.domain.com<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">MX is mandatory to receive email on your Raspberry Pi. The other ones are just easy-to-remember names for access to your emails.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Changes may take up to 24 hours before applying.<br>You can monitor the progress of the changes with an online tool like <a rel=\"noopener\" data-lasso-id=\"2376\" href=\"https:\/\/network-tools.com\/\" target=\"_blank\">Network-Tools.com<\/a>.<br>Choose &#8220;DNS&#8221; in the &#8220;Tool&#8221; dropdown, and type the domain or subdomain you want to check. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Your Battle Plan<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you need an overview of everything I&#8217;ll explain in this guide, here is a quick draw of everything we need:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2022\/08\/email-server-schema.jpg\" alt=\"\" class=\"wp-image-12311\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2022\/08\/email-server-schema.jpg 800w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2022\/08\/email-server-schema-300x188.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2022\/08\/email-server-schema-768x480.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s hard to put everything on the same schema without being too hard to read, but feel free to come back to this at anytime if you are a bit lost in the steps below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Postfix to Send Emails<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s move on to the main things and to the installation of Postfix.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Postfix will be the base of our mail server.<\/strong><br>It will allow us to send and receive emails corresponding to our domain name.<br>In this step, we&#8217;ll learn how to send emails.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As for any tutorial, start by doing the system updates if not already done:<br><code>sudo apt update<br>sudo apt upgrade<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You can then install the Postfix package:<\/strong><br><code>sudo apt install postfix<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">During the installation, you&#8217;ll have to choose these two configuration options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The general type of&nbsp;mail configuration<\/strong>: Internet site<\/li>\n\n\n\n<li><strong>System mail name<\/strong>: domain.com<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"474\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/postfix_install-1024x474.jpg\" alt=\"\" class=\"wp-image-42171\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/postfix_install-1024x474.jpg 1024w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/postfix_install-300x139.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/postfix_install-768x356.jpg 768w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/postfix_install.jpg 1250w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Now that installation is done, we&#8217;ll make two changes to the config that has been generated:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open the configuration file: <\/strong><br><code>sudo nano \/etc\/postfix\/main.cf <\/code><br>If you are not used to nano, I would recommend <a rel=\"noreferrer noopener\" href=\"https:\/\/raspberrytips.com\/nano-commands-shortcuts\/\" data-type=\"post\" data-id=\"2524\" target=\"_blank\">reading this article first<\/a>. I explain the basics as well as the most important shortcuts you can use in Nano.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/raspberrytips.com\/disable-ipv6-raspberry-pi\/\" data-type=\"post\" data-id=\"23187\">Disable IPv6 management<\/a><\/strong>:\n<ul class=\"wp-block-list\">\n<li>Replace:<br><code>inet_protocols = all <\/code><\/li>\n\n\n\n<li>With:<br><code>inet_protocols = ipv4  <\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Enter your domain name as myhostname<\/strong>:<br><code>myhostname= domain.com <\/code><\/li>\n\n\n\n<li>If you are on a local network, most of the Internet providers don&#8217;t allow sending emails directly.<br>So, you may need to add a relay host in your configuration.<br>Ask your provider for the server to use as a relay:<br><code>relayhost = smtp.yourprovider.com <\/code><br>You can also use Gmail as your relay (username and password will be required in your configuration file).<\/li>\n\n\n\n<li><strong>Save and exit<\/strong> (CTRL+O, Enter, CTRL+X).<\/li>\n\n\n\n<li><strong>Restart Postfix<\/strong>:<br><code>sudo systemctl restart postfix <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, the server should start properly without startup errors.<br>If this is not the case, look to solve these problems before continuing.<\/p>\n\n\n\r\n\t\t<!-- wp:paragraph -->\r\n\t<p  id=\"inpost_lm_linux_commands\"><b>Tip: <\/b> Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them.\u00a0You can <a rel=\"noreferrer noopener\" href=\"https:\/\/raspberrytips.com\/downloads\/?source=rb_linux&lm=4\" target=\"_blank\">grab the PDF here<\/a> if you want to save some time.<\/p>\r\n\t<!-- \/wp:paragraph -->\r\n\t\t\n\n\n<h3 class=\"wp-block-heading\">Testing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll now make our first test by sending an email from the Raspberry Pi.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Telnet<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">For this test, we&#8217;ll use telnet to connect to postfix.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install telnet: <br><code>sudo apt install telnet <\/code><\/li>\n\n\n\n<li>Connect to the SMTP server: <br><code>telnet localhost 25 <\/code><\/li>\n\n\n\n<li>Enter this series of commands:\n<ul class=\"wp-block-list\">\n<li><code>ehlo<\/code><\/li>\n\n\n\n<li><code>mail from: you@domain.com<\/code><\/li>\n\n\n\n<li><code>rcpt to: user@mail.com<\/code><\/li>\n\n\n\n<li><code>data<\/code><\/li>\n\n\n\n<li><code>Subject: test<\/code><\/li>\n\n\n\n<li><code>Test<\/code><\/li>\n\n\n\n<li><code>.<\/code><\/li>\n\n\n\n<li><code>quit<\/code> <\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>This&nbsp;command sequence will create an email and send it to user@mail.com (external email address).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the full trace:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pi@raspberrypi:~ $ telnet localhost 25\nTrying&nbsp;::1...\nTrying 127.0.0.1...\nConnected to localhost.\nEscape character is '^]'.\n220 domain.com ESMTP Postfix (Raspbian)\nehlo domain.com\n250-domain.com\n250-PIPELINING\n250-SIZE 10240000\n250-VRFY\n250-ETRN\n250-STARTTLS\n250-ENHANCEDSTATUSCODES\n250-8BITMIME\n250-DSN\n250 SMTPUTF8\nmail from: me@domain.com\n250 2.1.0 Ok\nrcpt to: youremail@gmail.com\n250 2.1.5 Ok\ndata\n354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;\nSubject: test\nTest\n.\n250 2.0.0 Ok: queued as 44EAE1FE54\nquit\n221 2.0.0 Bye<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Mailutils<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you are looking for a most friendly way to do this, you can install mailutils to use the mail command.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install mailutils: <br><code>sudo apt install mailutils <\/code><\/li>\n\n\n\n<li>Send a test email with the mail command: <br><code>echo 'Test' | mail -s \"Test mail command\" you@gmail.com <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In both cases, you can follow the email by <a href=\"https:\/\/raspberrytips.com\/journalctl-linux-command\/\">viewing the logs with journalctl<\/a>:<br><code>journalctl -u postfix@-.service<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Debugging<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Either way, you can check the log file \/var\/log\/mail.log to see what happens if you didn&#8217;t receive the email.<br><strong>If everything works correctly, you should see something like this: <\/strong><br><code>Jul 1 04:14:32 raspberrypi postfix\/local[5433]: 734AA1FF96: to=, relay=local, delay=0.09, delays=0.01\/0.04\/0\/0.04, dsn=2.0.0, status=sent (delivered to mailbox)<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Receive Emails With Postfix<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #000000;\">Now it&#8217;s time to edit our Postfix configuration to receive emails<\/span>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll do this by using the Maildir mailboxes format.<br><strong>Maildir is a safe and easy way to store emails: each mailbox is a directory, and each email is a file<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Edit the configuration file: <br><code>sudo nano \/etc\/postfix\/main.cf <\/code><\/li>\n\n\n\n<li>Add these lines at the end of the file: <br><code>home_mailbox = Maildir\/ <br>mailbox_command = <\/code><br>This&nbsp;configuration will tell Postfix to create a Maildir folder for each system user.<br>This folder will now host your new incoming emails. <\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need to create the Maildir folder template by following these steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install this packages: <br><code>sudo apt install dovecot-common dovecot-imapd <\/code><\/li>\n\n\n\n<li>Create folders in the template directory: <br><code>sudo maildirmake.dovecot \/etc\/skel\/Maildir <br>sudo maildirmake.dovecot \/etc\/skel\/Maildir\/.Drafts <br>sudo maildirmake.dovecot \/etc\/skel\/Maildir\/.Sent <br>sudo maildirmake.dovecot \/etc\/skel\/Maildir\/.Spam <br>sudo maildirmake.dovecot \/etc\/skel\/Maildir\/.Trash <br>sudo maildirmake.dovecot \/etc\/skel\/Maildir\/.Templates <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These templates will be used when you <a rel=\"noopener\" href=\"https:\/\/raspberrytips.com\/new-user-on-raspberry-pi\/\" data-type=\"post\" data-id=\"3322\" target=\"_blank\" data-lasso-id=\"2377\">add new users on your Raspberry Pi<\/a>.<br>But for those already&nbsp;existing, you have to&nbsp;do it manually.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you have to run these commands for your current user:<br><code>sudo cp -r \/etc\/skel\/Maildir \/home\/$USER\/ <br>sudo chown -R $USER:$USER \/home\/$USER\/Maildir<br>sudo chmod -R 700 \/home\/$USER\/Maildir<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You can now repeat the same kind of&nbsp;test as before, but put the user pi in the receiver:<\/strong><br><code>echo \"Test\" | mail -s \"Test\" $USER@domain.com<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And then check that the mail has arrived in the Maildir folder:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted EnlighterJSRAW\"><strong>pi@raspberrypi:~ $ cat \/home\/$USER\/Maildir\/new\/1625109614.Vb302I205f1M127492.raspberrypi<br><\/strong> Return-Path: <br> X-Original-To: pi@rpi.tips<br> Delivered-To: pi@rpi.tips<br> Received: by rpi.tips (Postfix, from userid 1000)<br>         id 1CC5A205F2; Thu,  1 Jul 2021 04:20:14 +0100 (BST)<br> Subject: Test mail command<br> To: pi@rpi.tips<br> X-Mailer: mail (GNU Mailutils 3.5)<br> Message-Id: 20210701032014.1CC5A205F2@rpi.tips<br> Date: Thu,  1 Jul 2021 04:20:14 +0100 (BST)<br> From: pi@raspberrypi<br> Test<br><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is a random example, your file won&#8217;t be named this way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should have only one mail in the new folder, use tab auto-completion to find it.<br><strong>As you can see the return path address is not correct, you have to&nbsp;change your hostname to fix this:<\/strong><br><code>sudo hostname domain.com<\/code><br>More details here on how to <a rel=\"noopener\" data-lasso-id=\"2378\" href=\"https:\/\/raspberrytips.com\/set-new-hostname-raspberry-pi\/\" data-type=\"post\" data-id=\"3406\" target=\"_blank\">change the hostname on a Raspberry Pi<\/a> (there is more to know).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But we have reached our goal for this step.<br>We received emails sent to our domain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Secure the Mail Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As I said at the beginning, there are some&nbsp;options to put in place to secure a minimum of the webserver.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Edit your configuration file: <br><code>sudo nano \/etc\/postfix\/main.cf <\/code><\/li>\n\n\n\n<li>Add these lines at the end of the file:<br><code>smtpd_helo_restrictions =<br>permit_mynetworks =<br>permit_sasl_authenticated =<br>reject_invalid_helo_hostname =<br>reject_non_fqdn_helo_hostname =<br>reject_unknown_helo_hostname =<br>check_helo_access =<br>hash:\/etc\/postfix\/helo_access =<\/code><\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This&nbsp;configuration will limit SMTP usage to the local network and reject people saying that&nbsp;they are from your domain name.<\/li>\n\n\n\n<li>Create the helo_access file:<br><code>sudo nano \/etc\/postfix\/helo_access <br><\/code>In this file, we need to put the list of domain names we want to block. <\/li>\n\n\n\n<li>Paste these lines into it:<br><code>X.X.X.X   REJECT <br>domain.com   REJECT <br>smtp.domain.com   REJECT <br>mail.domain.com   REJECT <\/code><br>Replace X.X.X.X with your public IP address. <\/li>\n\n\n\n<li>Restart postfix daemon:<br><code>sudo service postfix restart <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Having a certain set of good practices in place to improve the overall security of the Raspberry Pi is also a good idea, especially if you are using this server for important email.<br>You can read my <a href=\"https:\/\/raspberrytips.com\/security-tips-raspberry-pi\/\" data-type=\"post\" data-id=\"1148\">17 security tips for Raspberry Pi<\/a> here, and I also recommend <a href=\"https:\/\/raspberrytips.com\/backup-raspberry-pi\/\" data-type=\"post\" data-id=\"716\">setting up a backup system<\/a>, as explained in this article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Dovecot to Allow POP and IMAP Connections<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We now have a functional and secure mail server.<br>So, we will move on to the next part, which is to make this mail server accessible to POP and IMAP clients via SASL authentication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As you may have noticed, we already installed Dovecot in the previous step to create Maildir folders.<br>The only thing left to do is to finalize the configuration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the Dovecot configuration file:<br><code>sudo nano \/etc\/dovecot\/dovecot.conf <\/code><\/li>\n\n\n\n<li>Remove IPV6 support:\n<ul class=\"wp-block-list\">\n<li>Replace:<br><code>#listen = *,&nbsp;:: <\/code><\/li>\n\n\n\n<li>With:<br><code>listen = *  <\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Open the Dovecot mail configuration file:<br><code>sudo nano \/etc\/dovecot\/conf.d\/10-mail.conf <\/code><\/li>\n\n\n\n<li>Edit the Maildir folder:\n<ul class=\"wp-block-list\">\n<li>Replace: <br><code>mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u <\/code><\/li>\n\n\n\n<li>With: <br><code>mail_location = maildir:~\/Maildir  <\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Open the Dovecot master configuration file: <br><code>sudo nano \/etc\/dovecot\/conf.d\/10-master.conf <\/code><\/li>\n\n\n\n<li>Tell Dovecot to listen for SASL authentification:\n<ul class=\"wp-block-list\">\n<li>Comment all lines from the default service auth paragraph (add # before each line).<\/li>\n\n\n\n<li>Add these lines at the end of the file: <br><code>service auth {<br>         unix_listener \/var\/spool\/postfix\/private\/auth {<br>                 mode = 0660 <br>                 user = postfix<br>                 group = postfix<br>         }<br> }  <\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Open the Dovecot auth configuration file:<br><code>sudo nano \/etc\/dovecot\/conf.d\/10-auth.conf <\/code><\/li>\n\n\n\n<li>Allow plaintext auth.\n<ul class=\"wp-block-list\">\n<li>Uncomment and edit this line:<br><code>#disable_plaintext_auth = yes <\/code><\/li>\n\n\n\n<li>To become this one:<br><code>disable_plaintext_auth = no  <\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Edit this line too:<br><code>auth_mechanisms = plain login <\/code><\/li>\n\n\n\n<li>Edit the Postfix configuration file:<br><code>sudo nano \/etc\/postfix\/main.cf <\/code><\/li>\n\n\n\n<li>Tell Postfix to use SASL (add these lines): <br><code>smtpd_sasl_type = dovecot <br>smtpd_sasl_path = private\/auth <br>smtpd_sasl_auth_enable = yes <\/code><\/li>\n\n\n\n<li>Restart Dovecot and Postfix: <br><code>sudo systemctl restart postfix<br>sudo systemctl restart dovecot <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Keep an eye on the log files, and you can use &#8220;sudo service X status&#8221; to check that the service is running correctly. <\/strong>As I told you previously, a misconfiguration can happen fast. But we&#8217;ll do another test now to make sure everything is good.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"385\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/dovecot_status-1024x385.jpg\" alt=\"\" class=\"wp-image-42172\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/dovecot_status-1024x385.jpg 1024w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/dovecot_status-300x113.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/dovecot_status-768x288.jpg 768w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/dovecot_status.jpg 1105w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Testing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>To test that SASL authentication works well, we will create a test user and try to connect to the mail server with it.<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">User Creation<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/raspberrytips.com\/new-user-on-raspberry-pi\/\" data-type=\"post\" data-id=\"3322\">Create a new user<\/a> with a login test and the password you want:<br><code>sudo adduser test<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Answer the questions related to the password (and remember it). The other questions are not mandatory (press Enter to skip them).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Get the Encoded Password<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">We need to get our password in a base64 encoded format.<br>You can get it with this command:<br><code>printf '\\0%s\\0%s' '[LOGIN]' '[PASSWORD]' | openssl base64<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Replace [LOGIN] and [PASSWORD] in this command with the ones you choose during the adduser command.<br>In my case (test\/password), the string displayed is&nbsp;AHRlc3QAcGFzc3dvcmQ=.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Log In<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>We can now retry a connection with telnet by specifying this string for identification.<br>The only change is that we need to use the AUTH PLAIN command to log in:<\/strong><br><code>telnet localhost 25<br>ehlo domain.com<\/code><code><br>AUTH PLAIN [base64_string]<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can quit after this if you get the &#8220;Authentication successful&#8221; message, or send another test email like the first time if you have any doubt.<br>Here is the full trace:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pi@raspberrypi:~ $ telnet localhost 25\nTrying&nbsp;::1...\nTrying 127.0.0.1...\nConnected to localhost.\nEscape character is '^]'.\n220 domain.com ESMTP Postfix (Raspbian)\nehlo domain.com\n250-domain.com\n250-PIPELINING\n250-SIZE 10240000\n250-VRFY\n250-ETRN\n250-STARTTLS\n250-AUTH PLAIN LOGIN\n250-ENHANCEDSTATUSCODES\n250-8BITMIME\n250 DSN\nAUTH PLAIN AHRlc3QAcGFzc3dvcmQ=\n235 2.7.0 Authentication successful\nmail from: me@domain.com\n250 2.1.0 Ok\nrcpt to: youremail@gmail.com\n250 2.1.5 Ok\ndata\n354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;\nSubject: test\nTest\n.\n250 2.0.0 Ok: queued as 44EAE1FE54\nquit\n221 2.0.0 Bye<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Enable IMAP<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Dovecot allows us to connect with IMAP (telnet localhost 143).<\/strong><br>But we now need to enable TLS for IMAP on the port 993.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Edit the Dovecot master configuration file: <br><code>sudo nano \/etc\/dovecot\/conf.d\/10-master.conf <\/code><\/li>\n\n\n\n<li>Enable listener on the port 993:<br>The configuration should look like this (there are a few lines to uncomment):<br><code>service imap-login {<br>  inet_listener imap {<br>    port = 143<br>  }<br>  inet_listener imaps {<br>    port = 993<br>    ssl = yes<br>  }<br>}<\/code><\/li>\n\n\n\n<li>Then edit the SSL configuration file:<br><code>sudo nano \/etc\/dovecot\/conf.d\/10-ssl.conf <\/code><\/li>\n\n\n\n<li>Make sure SSL is enabled at the beginning of the file:<br><code>ssl = yes <\/code><\/li>\n\n\n\n<li>The certificate locations should also be uncommented:<br><code>ssl_cert = &lt;\/etc\/dovecot\/private\/dovecot.pem <br>ssl_key = &lt;\/etc\/dovecot\/private\/dovecot.key<\/code><\/li>\n\n\n\n<li>Finally, restart Dovecot server: <br><code>sudo systemctl restart dovecot <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can now check that your IMAPS server is working, with this command:<br><code>openssl s_client -connect localhost:993<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The login syntax is: <br><code>a login [LOGIN] [PASSWORD]<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The full trace should look something like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.\n<strong>a login pi password\n<\/strong>a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SPECIAL-USE] Logged in\n<strong>b select inbox\n<\/strong>* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\n* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft \\*)] Flags permitted.\n* 3 EXISTS\n* 0 RECENT\n* OK [UNSEEN 1] First unseen.\n* OK [UIDVALIDITY 1536038369] UIDs valid\n* OK [UIDNEXT 4] Predicted next UID\nb OK [READ-WRITE] Select completed (0.000 + 0.000 secs).\n<strong>b logout\n<\/strong>* BYE Logging out\nb OK Logout completed (0.000 + 0.000 secs).\nclosed<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can now connect to your IMAP server from any client on the LAN.<br>If you want to access your server from anywhere, don&#8217;t forget to open the needed ports in your router firewall.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Related article: <a href=\"https:\/\/raspberrytips.com\/installing-openssl-on-linux\/\" data-type=\"post\" data-id=\"15609\">Installing OpenSSL on Ubuntu\/Linux: A step-by-step guide<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Set Up Roundcube to Add Webmail Access<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the work is done, but we will push a little more and add a Webmail server to our mail server on Raspberry Pi.<br><a rel=\"noopener\" href=\"https:\/\/roundcube.net\/\" data-lasso-id=\"2379\">Roundcube<\/a> is a modern free and open-source webmail software.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The big advantage of Roundcube compared to other webmails is that it&#8217;s available directly in the Debian and therefore Raspberry Pi OS repositories.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you started from a blank Raspberry Pi OS, you would need to install a MySQL server first (MariaDB).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MySQL Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you don&#8217;t have one yet, you need to <a href=\"https:\/\/raspberrytips.com\/install-mariadb-raspberry-pi\/\" data-type=\"post\" data-id=\"3265\" target=\"_blank\" rel=\"noreferrer noopener\">install a MySQL server<\/a> to store the Roundcube database:<br><code>sudo apt install mariadb-server<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then you need to follow these steps to set a root password, and create a Roundcube user:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initialize the MySQL server by setting up a root password:<br><code>sudo mysql_secure_installation<\/code><br>You can keep all the default values (press Enter at each question), just enter a new password for &#8220;root&#8221; (the administrator).<\/li>\n\n\n\n<li>Connect with root (we need sudo because only root can access):<br><code>sudo mysql -uroot -p <\/code><br>Type the password you just set to log in.<\/li>\n\n\n\n<li>Create a new user for Roundcube:<br><code>CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password'; <\/code><br>Replace &#8220;password&#8221; with your chosen password <\/li>\n\n\n\n<li>Create the Roundcube database. <br><code>CREATE DATABASE roundcubemail; <\/code><\/li>\n\n\n\n<li>Give all privileges to the Roundcube user on the Roundcube database:<br><code>GRANT ALL PRIVILEGES ON roundcubemail.* to 'roundcube'@'localhost'; <\/code><\/li>\n\n\n\n<li>Quit the MySQL console:<br><code>FLUSH PRIVILEGES; <br>quit <\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Your database server is ready, move to the next step.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Roundcube<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To install it, enter the following command:<br><code>sudo apt install roundcube roundcube-plugins<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This will also automatically install all other dependencies (mainly <a href=\"https:\/\/raspberrytips.com\/web-server-setup-on-raspberry-pi\/\" data-type=\"post\" data-id=\"1017\" target=\"_blank\" rel=\"noreferrer noopener\">Apache<\/a>, PHP, and MySQL client).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Again, the installation wizard will ask you these questions about your MySQL server:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Configure database with dbconfig-common? <strong>Yes<\/strong>.<\/li>\n\n\n\n<li>MySQL application password for Roundcube: <strong>Your Roundcube user password<\/strong>.<\/li>\n\n\n\n<li>Database administrator password:&nbsp;<strong>your MySQL root password<\/strong>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-verse\"><strong>Note<\/strong>: I got a connection error at this step, but when choosing \"retry\" I could edit all settings including the database name, and it was OK after that.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now edit the apache configuration for Roundcube to enable the web app:<br><code>sudo nano \/etc\/apache2\/conf-enabled\/roundcube.conf<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Uncomment the first line:<br><code>Alias \/roundcube \/var\/lib\/roundcube<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then restart your web server:<br><code>sudo systemctl restart apache2<br><\/code>And go to http:\/\/[RASPBERRY-IP]\/roundcube to pull up the web interface.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"415\" src=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/roundcube_login.jpg\" alt=\"\" class=\"wp-image-42188\" srcset=\"https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/roundcube_login.jpg 865w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/roundcube_login-300x144.jpg 300w, https:\/\/raspberrytips.com\/wp-content\/uploads\/2021\/07\/roundcube_login-768x368.jpg 768w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">If you get any error, you can restart the installation wizard with this command:<br><code>sudo dpkg-reconfigure roundcube-core<\/code><br>It will also give you the chance to set a default server if you prefer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can now log in with your credentials created in the previous step,.<br>Enjoy your webmail now, and remember that it is possible to add many plugins on RoundCube to extend its features.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Logs and Configuration File Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So we saw how to set up a full mail server on Raspberry Pi.<br>If you have had any errors, or want to go further, here is the summary of the file locations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Postfix<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we are using Postfix to send and receive emails, it&#8217;s the core of the mail server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configuration<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/etc\/postfix\/main.cf: Main configuration for Postfix.<\/li>\n\n\n\n<li>\/etc\/postfix\/master.cf&nbsp;: Processes configuration for Postfix.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Log files<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>journalctl -u postfix@-.service<\/code><br>Here you can see all mail traces, and errors if there are any.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Dovecot<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We installed Dovecot to manage IMAP connections with a SASL security layer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configuration<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/etc\/dovecot\/dovecot.conf: The main configuration of Dovecot.<\/li>\n\n\n\n<li>\/etc\/dovecot\/conf.d\/: This subfolder contains several files with each part of the configuration to easily know where the option&nbsp;you&#8217;re looking for is.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Log files<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>journalctl -u dovecot<\/code><br>Dovecot doesn&#8217;t have a specific log file, it&#8217;s using the main syslog file.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Apache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Apache is used in this tutorial to run Roundcube.<br>Normally you shouldn&#8217;t need to change something unless Roundcube is not accessible at all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configuration<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/etc\/apache2\/apache2.conf: The main configuration file for apache2.<\/li>\n\n\n\n<li>\/etc\/apache2\/conf-enabled\/: Here you will find the configuration for some Apache services (like Roundcube.conf).<\/li>\n\n\n\n<li>\/etc\/apache2\/sites-enabled\/: Here you will find the configuration for any Apache website.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Log files<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/var\/log\/apache\/error.log<br>If you get any errors with Apache, you can find them here.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Roundcube<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">And finally, we installed Roundcube to add webmail to our mail server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configuration<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/etc\/roundcube\/config.inc.php: Here is the main configuration file for Roundcube.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Log files<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/var\/log\/roundcube\/errors<br>If you get some&nbsp;issue with Roundcube, you&#8217;ll find the errors in this file.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">And here we are at the end of this tutorial.<br>You have learned to set up a complete mail server with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Postfix for transport.<\/li>\n\n\n\n<li>Dovecot for secure authentication.<\/li>\n\n\n\n<li>Roundcube for web access to your emails.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">As you may have noticed, it&#8217;s not a simple thing to set up. There are a lot of configuration options, and it can be a lot of work to put that in place at home.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I think in most cases, the first part with Postfix is the one that will interest you.<br>You are going to be able to&nbsp;send emails from your <a href=\"https:\/\/raspberrytips.com\/raspberry-pi-beginners-projects\/\" data-type=\"post\" data-id=\"7423\" target=\"_blank\" rel=\"noreferrer noopener\">different projects<\/a>, but not necessarily to set up all the other steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In any case, if you really need to install everything, you know how to do.<\/p>\n\n\n<section id=\"end-block-pi\">\r\n<div class=\"rt-community-card \">\r\n\t<div class=\"rt-community-card__inner\">\r\n\r\n\t\t<div class=\"rt-community-card__main\">\r\n\t\t\t<h3 class=\"rt-community-card__headline\">\r\n\t\t\t\tNot getting the same result?\t\t\t<\/h3>\r\n\r\n\t\t\t<p class=\"rt-community-card__description\">\r\n\t\t\t\tEven when you follow every step, small differences in OS version, hardware or config can change the outcome. Instead of wasting time guessing, get help from people who have already fixed the same kind of issue.\t\t\t<\/p>\r\n\r\n\t\t\t<div class=\"rt-community-card__actions\">\r\n\t\t\t\t<a class=\"rt-community-card__button\" href=\"https:\/\/raspberrytips.com\/school\/community\/?coupon=EBCTY\">\r\n\t\t\t\t\t<span>Ask your question now<\/span>\r\n\t\t\t\t\t<span class=\"rt-community-card__button-arrow\">\u2192<\/span>\r\n\t\t\t\t<\/a>\r\n\r\n\t\t\t\t\t\t\t\t\t<div class=\"rt-community-card__small\">\r\n\t\t\t\t\t\t<span class=\"rt-community-card__small-lock\">\ud83d\udd12<\/span>\r\n\t\t\t\t\t\tNo risk. Cancel anytime.\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t<\/div>\r\n\r\n\t\t\t\t\t<div class=\"rt-community-card__side\">\r\n\t\t\t\t<ul class=\"rt-community-card__benefits\">\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Get help on your exact issue<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Access step-by-step videos for tricky setups<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t<li>Browse the website without ads<\/li>\r\n\t\t\t\t\t\t\t\t\t<\/ul>\r\n\t\t\t<\/div>\r\n\t\t\r\n\t<\/div>\r\n<\/div>\r\n<\/section>\r\n\r\n<style>\r\n.rt-community-card {\r\n\t--rt-bg: #f7f7f9;\r\n\t--rt-border: #e4e4e8;\r\n\t--rt-text: #15171b;\r\n\t--rt-muted: #5b6270;\r\n\t--rt-accent: #C61E4A;\r\n\t--rt-accent-hover: #aa183f;\r\n\t--rt-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);\r\n\r\n\tmargin: 36px 0;\r\n\tcolor: var(--rt-text);\r\n\tfont-family: inherit;\r\n}\r\n\r\n.rt-community-card__inner {\r\n\tdisplay: grid;\r\n\tgrid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.95fr);\r\n\tgap: 34px;\r\n\talign-items: start;\r\n\tbackground: var(--rt-bg);\r\n\tborder: 1px solid var(--rt-border);\r\n\tborder-radius: 22px;\r\n\tpadding: 34px 36px;\r\n\tbox-shadow: var(--rt-shadow);\r\n}\r\n\r\n.rt-community-card__main {\r\n\tmin-width: 0;\r\n}\r\n\r\n.rt-community-card__side {\r\n\tborder-left: 1px solid #e1e1e6;\r\n\tpadding-left: 28px;\r\n}\r\n\r\n.rt-community-card__benefits {\r\n\tmargin: 6px 0 0;\r\n\tpadding: 0;\r\n\tlist-style: none;\r\n\tdisplay: grid;\r\n\tgap: 18px;\r\n}\r\n\r\n.rt-community-card__benefits li {\r\n\tposition: relative;\r\n\tpadding-left: 18px;\r\n\tfont-size: 18px;\r\n\tline-height: 1.55;\r\n\tcolor: var(--rt-text);\r\n}\r\n\r\n.rt-community-card__benefits li::before {\r\n\tcontent: \"\";\r\n\tposition: absolute;\r\n\tleft: 0;\r\n\ttop: 0.72em;\r\n\twidth: 7px;\r\n\theight: 7px;\r\n\tborder-radius: 999px;\r\n\tbackground: var(--rt-accent);\r\n\ttransform: translateY(-50%);\r\n}\r\n\r\n.rt-community-card__actions {\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\talign-items: flex-start;\r\n\tgap: 10px;\r\n\tmargin-top: 30px;\r\n}\r\n\r\n.rt-community-card__button {\r\n\tdisplay: inline-flex;\r\n\talign-items: center;\r\n\tjustify-content: center;\r\n\tgap: 10px;\r\n\tmin-height: 60px;\r\n\tpadding: 0 28px;\r\n\tborder-radius: 14px;\r\n\tbackground: var(--rt-accent);\r\n\tcolor: #fff !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 21px;\r\n\tfont-weight: 700;\r\n\tline-height: 1;\r\n\tbox-shadow: 0 12px 22px rgba(198, 30, 74, 0.22);\r\n\ttransition: background .2s ease, transform .2s ease, box-shadow .2s ease;\r\n}\r\n\r\n.rt-community-card__button:hover {\r\n\tbackground: var(--rt-accent-hover);\r\n\tcolor: #fff !important;\r\n\ttransform: translateY(-1px);\r\n\tbox-shadow: 0 14px 26px rgba(198, 30, 74, 0.28);\r\n}\r\n\r\n.rt-community-card__button-arrow {\r\n\tfont-size: 20px;\r\n\tline-height: 1;\r\n}\r\n\r\n.rt-community-card__small {\r\n\tfont-size: 15px;\r\n\tline-height: 1.5;\r\n\tcolor: #6a717d;\r\n\tpadding-left: 2px;\r\n}\r\n\r\n.rt-community-card__small-lock {\r\n\tmargin-right: 6px;\r\n\tfont-size: 14px;\r\n\tvertical-align: baseline;\r\n}\r\n\r\n\/* Tablet *\/\r\n@media (max-width: 900px) {\r\n\t.rt-community-card {\r\n\t\tmargin: 28px 0;\r\n\t}\r\n\r\n\t.rt-community-card__inner {\r\n\t\tgrid-template-columns: 1fr;\r\n\t\tgap: 24px;\r\n\t\tpadding: 28px 24px;\r\n\t}\r\n\r\n\t.rt-community-card__side {\r\n\t\tborder-left: 0;\r\n\t\tborder-top: 1px solid #e1e1e6;\r\n\t\tpadding-left: 0;\r\n\t\tpadding-top: 22px;\r\n\t}\r\n\r\n\t.rt-community-card__benefits {\r\n\t\tgrid-template-columns: 1fr;\r\n\t\tgap: 12px;\r\n\t}\r\n}\r\n\r\n\/* Mobile *\/\r\n@media (max-width: 640px) {\r\n\t.rt-community-card__inner {\r\n\t\tpadding: 22px 18px;\r\n\t\tborder-radius: 18px;\r\n\t\tgap: 20px;\r\n\t}\r\n\t\r\n\t.rt-community-card__side {\r\n\t\tpadding-top: 18px;\r\n\t}\r\n\r\n\t.rt-community-card__benefits li {\r\n\t\tfont-size: 16px;\r\n\t}\r\n\r\n\t.rt-community-card__actions {\r\n\t\tmargin-top: 24px;\r\n\t\talign-items: stretch;\r\n\t}\r\n\r\n\t.rt-community-card__button {\r\n\t\twidth: 100%;\r\n\t\tmin-height: 56px;\r\n\t\tfont-size: 18px;\r\n\t\tpadding: 0 20px;\r\n\t}\r\n\r\n\t.rt-community-card__small {\r\n\t\ttext-align: center;\r\n\t\tpadding-left: 0;\r\n\t}\r\n}\r\n<\/style>\r\n\t\r\n","protected":false},"excerpt":{"rendered":"<p>Setting up your own mail server can be tricky&#8230; I\u2019ve done it a few times, and it\u2019s never as straightforward as it sounds. Whether you&#8217;re aiming for a simple SMTP setup or a full webmail suite, I&#8217;ll break down the key steps to help you get it running smoothly. Postfix is the main service to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":8481,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to-tutorials"],"taxonomy_info":{"category":[{"value":2,"label":"How-To Tutorials"}]},"featured_image_src_large":["https:\/\/raspberrytips.com\/wp-content\/uploads\/2018\/09\/mail-server-raspberry-pi-1024x683.jpg",1024,683,true],"author_info":{"display_name":"Patrick Fromaget","author_link":"https:\/\/raspberrytips.com\/author\/admin\/"},"comment_info":58,"category_info":[{"term_id":2,"name":"How-To Tutorials","slug":"how-to-tutorials","term_group":0,"term_taxonomy_id":2,"taxonomy":"category","description":"","parent":0,"count":228,"filter":"raw","cat_ID":2,"category_count":228,"category_description":"","cat_name":"How-To Tutorials","category_nicename":"how-to-tutorials","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/comments?post=660"}],"version-history":[{"count":44,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/660\/revisions"}],"predecessor-version":[{"id":51337,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/posts\/660\/revisions\/51337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/media\/8481"}],"wp:attachment":[{"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/media?parent=660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/categories?post=660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberrytips.com\/wp-json\/wp\/v2\/tags?post=660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}