Self-hosting a mail server is often complicated and messy. To begin with, there is an entire elaborate mechanism of sending and receiving emails, securely, that needs to be established. We need some mechanism to accommodate various users. Try and filter out spams. Try and avoid being falsely flagged as spam.
This list goes on and on, and it does require a certain level of manual intervention for smooth functioning. You cannot just install it and forget about it. However, the first installation is what scares most people away. This is where Postal comes into the picture, Postal does depend on quite a few pieces of software. To begin with it has to maintain a MySQL database and a RabbitMQ virtual host.
Fortunately, for us, most of the intricate configuration is automated via a shell script. All we have to do is fetch the shell script and run.
- VPS with at least 4 GB of RAM and at least 20 GB of storage.
- Two static public IP address pointing to the server (recommended not necessary).
- Newly installed Ubuntu 16.04, on the said VPS.
Seeing how most of the installation can be automated, Postal’s GitHub repository comes with a quick install script, we can fetch that script by running:
$curl -O https://raw.githubusercontent.com/atech/postal/master/script/install/ubuntu1604.sh
Next, you may want to open up the text file
ubuntu1604.sh, created in the directory where you ran the above command. Look for the sections MySQL and RabbitMQ and underneath each of them, there is the default password for MySQL and RabbitMQ which is
'p0stalpassw0rd' replace it with something secure.
Also there’s a mistake in the script, it tries to reload nginx, when it is not running in the first place. To fix that go to the bottom of the screen and look for the line
$service nginx reload
Change this with the following line:
$service nginx start
To make the script an executable, run the following command in the same directory as the installation script.
$chmod +x ubuntu1604.sh # To run the script give the following command, again in the same directory. $./ubuntu1604.sh
Once this is done, you are ready to make your initial user account, just run:
Then enter the email address your name and password. After this you would want to open the files
Here, replace every occurrence of postal.example.com or any other such generic name with your registered domain name by which you want your email server to be known.
Open the file
/opt/postal/config/postal.yml and change the entries of the DNS section to the domain name of your choice. Feel free to go through other entries of generic domain names and replace them too. In the example below, the domain name used is just ranvirblog.com feel free to use your domain name with any reasonable sub domain like mail.mydomainname.com
dns: # Specifies the DNS record that you have configured. Refer to the documentation at # https://github.com/atech/postal/wiki/Domains-&-DNS-Configuration for further # information about these. mx_records: - mx.ranvirblog.com smtp_server_hostname: ranvirblog.com spf_include: spf.ranvirblog.com return_path: rp.ranvirblog.com dkim_identifier: postal domain_verify_prefix: postal-verification custom_return_path_prefix: psrp
To access the main interface, add the following DNS records using your DNS provider’s interface.
- An A record for
- An A record for track.yourdomain.com
Interface and Getting Started
Now that you are ready to access the interface and start using Postal. Visit,
https://yourdomain.com and enter your initial email address and password that you chose after running the postal make-user command. After which the interface asks for Organization Setup. Add in the name of your organization and from there go to the next prompt for
Build A New Server.
Enter a reasonable name and let the mode stay on ‘Live’ and click on build server. From here you will be taken to your mail server management interface. Here, click on the top left menu that say “Domains”.
Click on “Add your first domain”. In my case, it is ‘ranvirblog.com’ your case can be very different, like mail.yourdomain.com. In any case, once you have entered your domain name you will be greeted by a screen that will show you step by step how to properly add each record.
Once you are satisfied with your domain name records, you can click on the “Check my records are correct” button on the top of the screen and it will verify whether or not everything is fine. You may want to keep all of the DKIM values private for security reasons. As an example, here is the DNS record list that worked with the server.
The next steps
Now we are ready to send our first email. Click on Messages from the black menu bar on the top of the screen. Then click on Send Message that appears below it.
The message would be queued for a while before being sent. Once you have successfully sent your first email via this server. It is time to set up actual set up the proper encryption key for secure SSL (we were using self-signed certificate all this while!)
$postal register-lets-encrypt [email protected]
Then you can proceed on to adding new users and also explore some of the spam mitigation options. You may also want to look into Click and Open Tracking Installing and running Spam Assassin is highly recommended, as well.
We hope you have enjoyed reading this post and found it useful. Feel free to reach out to our support crew in the case of any issues, we offer 24/7 WordPress support at a ridiculously low price. If you liked this article, then please subscribe to our mailing list for WordPress video tutorials. You can also find us on Twitter and Facebook.