How to Install Postal Mail Server on Ubuntu 16.04 & 14.04

In this article, we will explain to you How to Install Postal Mail Server on Ubuntu 16.04 & 14.04.

Postal is a complete and fully featured mail server for use by websites & web servers. Think Sendgrid, Mailgun or Postmark but open source and ready for you to run on your own servers. Postal was developed by aTech Media to serve its own email processing requirements and we have since decided that it should be released as an open source project for the community.

You will need a VPS Server with Ubuntu 16.04 or 14.04 installed on it.If you don’t have VPS server, you can get it by following this link.

First, install some dependencies by running this command:
sudo apt-get install python-software-properties software-properties-common

And install Nginx, MariaDB, and Git.
sudo apt-get install git nginx mariadb-server build-essential libmysqlclient-dev

After, install Node.js by running these commands
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs

Now install Ruby which is required.
Note: Prefered Ruby 2.3 version or higher

First, add Ruby repository
sudo apt-add-repository ppa:brightbox/ruby-ng -y
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

Update the system
sudo apt-get update
Install Ruby
sudo apt-get install -y ruby2.3 ruby2.3-dev

You have successfully installed Ruby.

Install RabbitMQ Server

Now install the RabbitMQ Server.

First, download RabbitMQ packages.
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
And install them
sudo dpkg -i erlang-solutions_1.0_all.deb
After installing the packages enable RabbitMQ:
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -

Update the system
sudo apt-get update
Now install RabbitMQ Server
sudo apt-get install erlang erlang-nox rabbitmq-server

After installing RabbitMQ, create a database:
mysql -u root -p
CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
Give previleges to postal database:
GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd";
Also in postal-%
GRANT ALL ON `postal-%`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd";
And flush the previleges.
FLUSH PRIVILEGES;

After, create a RabbitMQ virtual host
rabbitmqctl add_vhost /postal
Next add user:
rabbitmqctl add_user postal passw0rd
And set the permissions:
rabbitmqctl set_permissions -p /postal postal ".*" ".*" ".*"

Install Postal Mail Server

To install Postal Mail Server, run commands one by one:
sudo useradd -r -m -d /opt/postal -s /bin/bash postal
setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3
sudo -i -u postal git clone https://github.com/atech/postal /opt/postal/app
ln -s /opt/postal/app/bin/postal /usr/bin/postal

After running, install procodile and bundler:
sudo gem install procodile bundler
Now its time to install postal:
su - postal
Install Postal bundle
postal bundle /opt/postal/app/vendor/bundle
Initialize by running this command
postal initialize-config
postal initialize

And start the postal:
postal start

To finish it, Create Postal Admin User:
postal make-user

You have successfully installed Postal Mail Server.

Enjoy!

postal

 

Register for free account now.