In this guide, we plan to show you how you can install Postal Mail Server on an Ubuntu 16.04 VPS. Postal is a feature-rich mail server application which generally gets used as an alternative to Sendgrid, MAilchimp, Mailgun and other similar SMPT servers. You could use Postal to send out bulk emails, newsletters and more. This tutorial can work on different Linux VPS systems but it was made and tested in a Ubuntu 16.04 VPS.
There are certain requirements for the Postal setup.
An Ubuntu VPS
Ruby version 2.3 or up, MySQL/MariaDB, RabbitMQ, Node.js and Git installed on your server
Step 1: Installing Basic Packages and Dependencies
Before we begin, we will need to install the packages and dependencies on your system, including nginx, mariadb, git and more.
[user]$ sudo apt-get install python-software-properties software-properties-common [user]$ sudo apt-get install git nginx mariadb-server build-essential libmysqlclient-dev
Step 2: Installing Node.js
Now, we will need to install the latest version of Node.js on the system. To install the latest 7.x version, use the command below:
[user]$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - [user]$ sudo apt-get install nodejs
Step 3: Installing Ruby 2.3
Once Nodejs is done installing, we will have to install Ruby and append the Ruby PPAs:
[user]$ sudo apt-add-repository ppa:brightbox/ruby-ng -y [user]$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
Now, install Ruby 2.3:
[user]$ sudo apt-get update [user]$ sudo apt-get install -y ruby2.3 ruby2.3-dev
Step 4: Install RabbitMQ Server
RabbitMQ is used for messaging, so we will want to enable the Erlang PPA by executing the command below:
[user]$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb [user]$ sudo dpkg -i erlang-solutions_1.0_all.deb
You also have to enable the RabbitMQ server PPA:
[user]$ echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list [user]$ wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add –
Now, you may install the RabbitMQ server along with its dependencies:
[user]$ sudo apt-get update [user]$ sudo apt-get install erlang erlang-nox rabbitmq-server
Step 5: Creating a Database in MySQL
We will need to create a database and a user for your Postal mail server and give permissions to the user:
[user]$ mysql -u root -p Enter password:******* mysql> CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci; mysql> GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd"; mysql> GRANT ALL ON `postal-%`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd"; mysql> FLUSH PRIVILEGES;
Be sure to sure a strong password.
Step 6: Creating the RabbitMQ VirtualHost
Next, we will want to create a VirtualHost in your RabbitMQ server and create a new user for your app:
[user]$ rabbitmqctl add_vhost /postal [user]$ rabbitmqctl add_user postal passw0rd [user]$ rabbitmqctl set_permissions -p /postal postal ".*" ".*" ".*"
Step 7: Installing and Configuring the Postal Mail Server
Since we’ve finished with the prerequisites we may move on to the actual Postal setup, for starters we will start with creating a user(account) called’postal’
[user]$ sudo useradd -r -m -d /opt/postal -s /bin/bash postal [user]$ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3
Next, we will duplicate the source code from the Postal Github repo and append a soft link to the postal binary file:
[user]$ sudo -i -u postal git clone https://github.com/atech/postal /opt/postal/app [user]$ ln -s /opt/postal/app/bin/postal /usr/bin/postal
In order to configure Postal, you have to install bundler and procodile. Do that with the command below:
[user]$ sudo gem install procodile bundler
For the installs to be done, we will switch to the portal user:
[user]$ su - postal [user]$ postal bundle /opt/postal/app/vendor/bundle [user]$ postal initialize-config [user]$ postal initialize
Now we will open the postal.yml file from /opt/postal/config and update it according to your setup.
Run Postal in the background by executing the following command:
[user]$ postal start
Step 8: Creating a Postal Admin User
In order to create the first Postal administrator account, execute make-user:
[user]$ postal make-user
Postal User Creator Enter the information required to create a new Postal user. This tool is usually only used to create your initial admin user. E-Mail Address : firstname.lastname@example.org First Name : DreamVPS Last Name : Admin Initial Password: : ********* User has been created with e-mail address email@example.com Again, use a strong password!
Step 9: Checking Postal Running Status
Since your Postal was successfully installed, configured and running. Check its status by executing the following command:
[user]$ postal status
Please confirm that every service is running and working correctly.
Step 10: Configuring Nginx with Postal
Postal has its own configuration file. You may copy the cfg file to your nginx directory. Swap the default configuration file or create a new one.
[user]$ cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default
On default, Postal only works with SSL. You may use a self-signed SSL.
[user]$ sudo mkdir /etc/nginx/ssl/ [user]$ sudo cd /etc/nginx/ssl/ [user]$ openssl req -x509 -nodes -newkey rsa:4096 -keyout postal.key -out postal.crt
Now, restart nginx so the changes take effect.
[user]$ sudo service nginx reload
You may now access the Postal dashboard from https Use the details from step 8.
The Postal installation is now done