• Home
  • |
  • Blog
  • |
  • Postal Setup 2021 Guide. (RabbitMQ and ERLANG issues fixed)

Postal Setup 2021 Guide. (RabbitMQ and ERLANG issues fixed)

February 23, 2021

UPDATE: Postal now uses docker.

What is Postal?

Install Postal using this document: https://install.postal.biswajitpradhan.com/

Thanks for visiting, many of my peers told that Postal can no longer be installed in one go like earlier where we only needed a script from postal and rest was just a piece of cake. Well, we all know Postal is one of the Best SMTPs ever and is being used widely. Few of the other SMTP software includes IRedmail and Exim, Postfix etc. We will be discussing about postal today, Postal was built by ATech Media before releasing it for Community Use. Necessity is the mother of all inventions, It is a similar case to this. Atech media wanted a very robust SMTP software inbuilt to meet their demands and once they built postal, They decided to let it go Open Source unlike any other provider would have tried to sell it.

A Special Thanks to the team for making such a powerful software open source.

Alright, lets come back to the topic. Like I say on my thumbnail, it’s no longer possible to install Postal in one go due to the dependencies like Erlang and RabbitMQ. However, there is always a way to go manually and still have postal installed on a VPS which has port 25 open.

There are only a handful of VPS Provider who now have Port 25 opened as there are lots of Players involved and are offering similar SMS SMTP through API for quite an economic pricing.

Few of the market leaders in terms of SMTP and APIs are:

AWS SES

Elastic Email

SendGrid.

Few VPS Providers which have the port 25 open:

Hostinger

HostWinds

Hostgator

Scala hosting

Interserver

However, we will stick to the discussion, like I said at one point in time, You might find any other Provider to become expensive suddenly while transacting in thousands of email. Email servers are clunky to manage but with a software like Postal, you can have a sleek and lightweight mailing software without losing on the quality and features it offers.

I tried to install the Software(Postal) using one line script which Atech Media shows in their website/github documentation. However, I failed. So, I went the manual method.

Steps to Follow:

First Get a VPS with Port 25 open. For this test – I took up the hostwinds VPS for 4.99$ a month with 1CPU and 1GB Memory. I would highly suggest you take a larger one if its for production usage. After sign up, I logged in to the server through Putty. People who dont know what Putty is can refer here.

Once you are logged in to the VPS as root. Follow the steps below to install Postal.

Check the hostname.

hostname -f

Connected my Domain shipped.co.in (another test domain which I own), You will need to point an A Record to hosting IP address. You can follow Godaddy Videos to do it.

I chose to use send.shipped.co.in and pointed an A record to my ip address. I did a test once the DNS propagated using MXtoolbox and saw the DNS now resolving to the correct IP address. From the hostwinds panel I set up rdns. RDNS is mandatory if you are planning to build an email server without which your mails will never reach inbox.

I then went ahead and changed my hostname from Step3 by doing a sudo hostname send.shipped.co.in (You will need to modify this according to how you want your sending domain to be)

sudo hostname send.shipped.co.in - You will need to modify this according to your domain name.

Once that is done go ahead and do a check again by typing in hostname -f – you should see the latest name you have given. (In my case , it is send.shipped.co.in

hostname -f

Then you will need to ensure all packages are updated. You can do it by typing

sudo apt update

Once the server is updated, go ahead and install MariaDB as we will need it for installing Postal.

sudo apt install mariadb-server libmysqlclient-dev

Once you see mariadb installed, you can install it by using

 sudo mysql_secure_installation

You should now see an interactive step by step installer. Go ahead and set it up. Once done Exit; to come out of SQL Query mode.

Now that you have SQL installed, Keep the root password handy as will need it shortly. We will proceed to install Postal and its other dependencies. Go to the terminal and type these one by one.

 

Most important Part: Dont Miss.

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb

Once that is done . Go to

cd /etc/apt/sources.list.d/
ls

You should now see the rabbitmq_rabbitmq-server.list  Add the below Repos into the rabbitmq_rabbitmq-server.list

deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner

You can do that by doing a

nano rabbitmq_rabbitmq-server.list

Once added do a

sudo apt-get update

You now should be ready to install Erlang, You will need to run the below

sudo apt-get install erlang
sudo apt install ruby2.3 ruby2.3-dev build-essential
sudo apt-get update

Install RabbitMQ

sudo apt-get install rabbitmq-server

Once installed stop, start and enable the RabbitMQ Server.

sudo systemctl stop rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server

If you see some errors here: RabbitMQ is not installed, Follow the above steps again. If it went through , Congrats you made it to the first milestone.

Now we need to add user and password for Postal.

sudo rabbitmqctl add_vhost /postal
sudo rabbitmqctl add_user postal p0stalpassw0rd
sudo rabbitmqctl set_permissions -p /postal postal "." "." ".*"
sudo apt install nodejs
sudo apt install git

Now its time to bring up our mariadb and set it up for Postal use.

sudo mysql -u root -p
CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'postal'@'127.0.0.1' IDENTIFIED BY 'p0stalpassw0rd';
GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "p0stalpassw0rd";
GRANT ALL PRIVILEGES ON `postal-%` . * to `postal`@`127.0.0.1` IDENTIFIED BY "p0stalpassw0rd";
FLUSH PRIVILEGES;
EXIT;

Install postal mail server: Now that we have prepped our SQL Database for Postal. We will download latest Postal and install it on our VPS.

Go ahead and create a Service Account

sudo useradd -r -m -d /opt/postal -s /bin/bash postal

Then go ahead and use the below commands for setting up ruby to talk to our postal application.

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3

Install the other required packages

sudo gem install bundler
sudo gem install procodile
sudo gem install nokogiri -v '1.7.2'

Install Postal in the correct directory. Use the below commands to set up postal inside of opt/ and give permission to Postal user we made earlier.

Create Symlink from opt/ to /usr/bin/postal

sudo mkdir -p /opt/postal/app
sudo wget https://postal.atech.media/packages/stable/latest.tgz
sudo tar xvf latest.tgz -C /opt/postal/app
sudo chown -R postal:postal /opt/postal
sudo ln -s /opt/postal/app/bin/postal /usr/bin/postal

Now its time to go ahead and initalize Postal. We can do that by typing the commands in the terminal.

postal bundle /opt/postal/vendor/bundle
postal initialize-config
postal initialize

Now we can go ahead and make an Administrative User for Logging in to Postal on our GUI(Browser Window)

postal make-user
Follow the Questions it asks and fill in the details as per need.

Now that we have made an admin user, We will need to install NGINX to go ahead and accept traffic on port 80 and 443.Before doing that we will check status of Postal. Do by typing the below in your terminal.

sudo -u postal postal start
sudo -u postal postal status - You should see Postal running.

Lets prepare for installing NGINX

sudo apt install nginx

Copy the Nginx Config file to Nginx.

sudo cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default

Lets go ahead and secure the Postal GUI with an SSL to encypt stuff we send. If you are using cloudflare as a Proxy in between, You can issue your postal installation a self declared SSL

sudo mkdir /etc/nginx/ssl/
sudo openssl req -x509 -newkey rsa:4096 -keyout /etc/nginx/ssl/postal.key-out /etc/nginx/ssl/postal.cert -days 365 -nodes
sudo systemctl stop nginx
sudo systemctl start nginx

However, If you are not using the Orange proxy enabled button on Cloudflare, I would higly recommend installing a Let’s Encyrpt SSL to your installation. Follow the steps below if you need a SSL from Let’s Encyrpt.

apt -y install certbot
certbot certonly --standalone -d send.shipped.co.in - Change the domain name after d and space.
sudo systemctl start nginx
systemctl restart nginx
systemctl start nginx

Next is to change/tweak the postal configurations. To do that you will need to CD into the postal directory.

cd /opt/postal/config and then  nano postal.yml

postal.yml update - Biswajit Pradhan

Restart Postal and check status.

postal restart
postal status

You should see the services running like the image given below. If not, check if you have missed anything above.

Postal Status Image - Biswajit Pradhan

 

Post Setup Configuration:

Now go ahead and open the postal software through your Browser and go to domain. You should see the login screen like this.

Postal Login Screen - Biswajit Pradhan

 

Login to the Postal using the steps we created earlier – Once you login you will be able to see the first splash page.

postal no domain - Biswajit Pradhan

 

 

Once you add the domain, You would see something like this.

added domain on postal smtp - Biswajit Pradhan

 

Then go ahead and click on Domain Name and check for DNS Setup. You will need to create SPF, DKIM, Return path and MX Records with your host. You can easily follow a tutorial of Godaddy on how to do it.

smtp - Biswajit Pradhan

 

Once that is one click VERIFY.

postal valid - Biswajit Pradhan

 

Done. You can now go to Credentials and create credentials.

credentials smtp postal - Biswajit Pradhan

 

Testing:

Name your credential and generate a Key. You should now be able to connect this SMTP with Mautic or any other tool of your choice. To Test it out I will recommend smtper.net and try sending an email.

smtper - Biswajit Pradhan

 

You should now see Mail Successfully Sent. Congratulations on installing Postal..

Follow a warmup schedule to keep your server warmed up. If you need a warmup schedule, send me an email with the size of your VPS and number of emails you would want to send per day/hour.

Once again, With a lot of Freedom, Postal also requires you to be responsible. Please follow email etiquette and ensure you are not spamming anyone. Starting to blast emails to unknown email addresses will start getting rejected by Reputed Mail Providers and eventually will land you in a spam trap . Instead take time to build reputation of the IP and Domain and ensure you are constantly keeping an eye on Blacklist and your Bounces, Abuses and Complaints. Answer them promptly and not repeat them.

Hope this helps. If you face issues, kindly drop a comment and I would love to get in touch.

About the author 

Biswajit Pradhan

I work as a Security and Vulnerability Remediation Specialist on Windows and Linux and I work for a Finance Technology Company based in India, I am building this blog to share my opinion with the world. I write mostly on Mautic, WordPress, Hosting, and Technological tips and Product reviews.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>