Mail-in-a-Box is a small, yet effective program that aims to create an easy to deploy, all-in-one email server solution in your machine. This tutorial shows you how you can install Mail-In-A-Box on Ubuntu Linux.
Why Host Your Own Email Server
One of the biggest advantages of hosting your own email server is that it gives you privacy over your own data. Unlike a webmail service such as Gmail, running Mail-in-a-Box guarantees that there is no middle man between you and your emails.
A self-hosted server also gives you the flexibility with how you want to interact with your email. For example, Gmail uses tags instead of folders for organizing messages. This often breaks offline clients that try and fetch email from Gmail accounts.
Lastly, hosting your own server lets you bypass identity checks when creating an email account. This is useful if you are privacy conscious and you do not want to share your information with third-party providers.
Good to know: Privacy practices does not stop at creating your own email server. Learn how you can further protect yourself online by installing a group collaboration software like Citadel.
Preparing Your Email Server
Before you can install Mail-in-a-Box, you need to make sure that you have a running server and a domain name. This article is done on an Ubuntu VPS from Digitalocean.
Tip: If you are already running your own VPS, you can also install the Mailcow email server.
To get started, you need to configure your domain as a name server that points to your own machine. This is important since Mail-in-a-Box manages its own DNS records internally.
Note: The configuration for each domain registrar is different, so we won’t go through the instruction to create a nameserver. What you need to do is to create two nameservers: ns1.your-domain-name.com and ns2.your-domain-name.com pointing to the IP address of your server. You should also change your domain’s nameserver record to the one you have created.
FYI: You should never use your Mail-in-A-Box server to run email marketing campaigns as you could risk your server’s IP address being banned. Make use of these email marketing platforms instead.
Updating Your Machine’s Hostname
With your domain name and nameserver properly configured, you need to now modify your machine’s hostname. This will allow Mail-in-a-Box to properly set its default values during installation.
You can do this in Digitalocean by doing the following:
- Go to your droplet’s status page.
- Click the droplet’s name, replace it with your domain name and click the check mark to save it.
- Login to your VPS instance as root and run the following command:
echo "box" > /etc/hostname
- Next, run the following command to change your machine’s “/etc/hosts” file to your current domain name:
awk '$1 == "127.0.1.1" { print $2 }' /etc/hosts | sed -i s/.*/box.yourdomain.here/ awk '$1 == "127.0.1.1" { print $3 }' /etc/hosts | sed -i s/.*/box/
- Reboot your machine to apply your new changes.
Installing Mail-in-a-Box
With those done, you can now start installing Mail-in-a-Box in your machine.
- Begin the process by obtaining Mail-in-a-Box’s installation script:
curl -s https://mailinabox.email/setup.sh | sudo -E bash
- Provide the email address that you want to use for your mail server.
- Provide a hostname for your mail server. In my case, I will use the default “box.myvpsserver.top.”
- The installation script will then ask you for a timezone. For this, you need to provide your current timezone instead of the server’s physical location.
- Write the password that you want to use for your email account.
Tip: If you are using Outlook instead, learn how you can schedule your emails in Outlook.
Configuring Your Email Server
At this point, you now have a properly installed Mail-in-a-Box server in your machine. However, you still need to configure some of its settings to use it properly.
- Open the link that the installer wrote at the end of the script.
When loading the website, your browser might throw a security exception at you. This is because Mail-in-a-Box uses a self-signed certificate for its initial website.
You can safely bypass this error by clicking “Advanced,” then “Accept the Risk and Continue.”
- Login to your Mail-in-a-Box instance by providing your new email account and password.
- Click “System,” then “TLS (SSL) Certificates.”
- Click the “Provision” button to create an SSL certificate for your server’s subdomains.
There are instances where Mail-in-a-Box will not request an SSL certificate for all of your subdomains. You can fix this by clicking the “Provision” button again.
- Click “System,” then “Status Checks” to confirm that everything is working properly.
Tip: Learn more about SSL and encryption by creating your own self-signed certificate using OpenSSL.
Sending and Verifying Your First Email
From here, you can now login and use your Mail-in-a-Box server. Unlike other self-hosted mail solutions, Mail-in-a-Box provides a simple and intuitive web interface that you can immediately use and start with. This means that you do not need to install any external mail clients to use Mail-in-a-Box.
- Access the web interface in your browser by typing: “https://yourdomain.com/mail.”
- Type your new email address and password in the server’s login page.
- Click the “Compose” button to create a new email message.
- Provide a valid email recipient and write a simple test message.
- Once done, click the “Send” button.
- Lastly, check whether your mail arrived to its intended recipient by loading its own inbox.
Tip: There are times when a disposable email is useful. Check out these providers for disposable and throwaway emails.
Frequently Asked Questions
Is it possible to reconfigure my email server after installation?
Yes. You can reconfigure any of the server’s internal settings by going to your machine’s console and running the following command: sudo mailinabox
.
Can I create a different email account in my Mail-in-a-Box server?
Yes. By default, Mail-in-a-Box allows you to create multiple email accounts in the same server. To do this, go to your Mail-in-a-Box administrator page, click “Mail & Users,” then “User.” This will load a prompt where you can provide an email address and password for a new user.
My mail is not arriving to its intended recipient.
The most likely cause of this is that your machine’s IP address is in an email blocklist. To fix this issue, you can either request for a new, “non-blocklist” IP address from your service provider or create a new VPS instance. Another way is to make use of a third-party SMTP server to help you send your mails.
Image credit: Brett Jordan via Unsplash. All alterations and screenshots by Ramces Red.
Our latest tutorials delivered straight to your inbox