As a basis for Mail-in-a-Box, I choose a VPS from my favorite host Hetzner and selected the Ubuntu 18.04 LTS operating system.
Before we start, the server must first be secured. I have already written instructions for this. Follow the steps in this article, and then come back to this post.
Step 1: Update the system
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get dist-upgrade
The first command in the first step updates the package files so that you install the latest packages with the 2nd command and the latest updates for Ubuntu with the 3rd command.
Step 2: Install required tools / programs
apt-get install git nano curl
With this command you install the text editor Nano, GIT and Curl.
Step 3: Set the host name
With the first command, check whether you have already set a host name or whether you still have to edit it.
If you get an output like “ms1”, you have to open the file /etc/hostname with this command and change the host name to “ms1.domain.xyz”:
sudo nano /etc/hostname
If you have adjusted the host name, you can close the editor with CTRL + X, then Y for saving and Enter for approving the file name.
Then restart the hostname service:
service hostname restart
Step 4: Install Mail-in-a-Box
First navigate to your standard directory with:
With the following command you load a script from the Mail-in-a-Box manufacturer and then execute it:
curl -s https://mailinabox.email/bootstrap.sh | sudo bash
After a short time, a pop-up opens in the terminal that welcomes you with the initial installation message. We close this either with the letter “o” or with the enter key.
Next, another popup will open asking you for the correct email address. By default, Mail-in-a-Box guess one, but you need e.g. firstname.lastname@example.org.
Again, Mail-in-a-Box asks you for something, namely the server address. Here you can enter a subdomain such as ms.domain.xyz, but this must later point to the server via IP, since the admin area, webmail, calendar and contacts are accessed via this domain.
The installation is almost done when Mail-in-a-Box asking you in which time zone you are at home. The default setting here is based on the server location of your provider. I just had to confirm my settings with the Enter key.
Finally, the installation script asks you for a password for the web admin. There is no popup for this, but is entered again in the command line.
Step 5: Webadmin & co.
After the installation is finished, you can log in via https://IP/admin or http://domain.xyz/admin with the e-mail and the password from the installation.
After logging in, you will be taken directly to a status page on which you will be informed about the general system status and other necessary and additional settings.
So that your emails do not end up in spam folders or are rejected by recipient servers, I recommend you create the following TXT entries at your domain host:
|@||v=spf1 a:ms.domain.xyz ip4:<Server-IP-V4> ip6:<Server-IP-V6> ~all||600 / Auto|
|_dmarc||v=DMARC1; p=quarantine; rua=mailto:email@example.com; ruf=mailto:firstname.lastname@example.org; sp=quarantine; fo=1:d:s; ri=864000; adkim=r; aspf=r||600 / Auto|
|mail._domainkey||See Mail-in-a-Box Webadmin => External DNS||600 / Auto|
All in all, you should now set the following domains to the IP of your server via A-Record at your hosting provider:
From now on you have your own mail server. Do you have questions about the installation or would you like to introduce me to a better alternative to Mail-in-a-Box? Please feel free to send me an email.
Picture © Daniel Wenzlik