Send and receive emails with an open source mail server. This article will assist you in installing and configuring the Postal mail server for your company.

Open Source Mail Server

Sending emails on different types of events is necessary for modern applications. Every business needs a reliable mail server for outgoing emails. Further, companies need a mail server for sending bulk emails for marketing campaigns, newsletters, and many other tasks. There is several open source mail server available for this. However, we will discuss the Postal server in detail in this post and cover the following topics.

What is Postal Mail Server?

Postal is a free and open source mail server. It is a full-featured mail server for websites and web applications. Postal mail server is an alternative to the existing popular mail server such as Sendgrid, and Mailgun. Postal is a robust, secure, and scalable open source email delivery platform. All the source code and documentation are available at GitHub. You can download, install it on your private server and keep full control over it. You can also improve and enhance it as per business needs. In addition, Postal mail server supports multiple organizations.

Users can view graphs and stats showing the volume of incoming & outgoing mails. In addition, you can access the full outgoing & incoming message queue. Postal mail server provides functionality for webhooks. You can set up webhooks to receive live information about delivery information in real-time. It also offers message retention that allows you to store and examine all send and received messages. Email delivery is very important in the business to ensure that users get the email. However, sometimes email does deliver to the user and you have to investigate the issue. The incoming and outgoing mail server also provides complete logging and tools to do the investigation.

Features of Postal

Postal mail server offers a lot of features. However, we will discuss the following key features in this article.

Sending Emails: Postal mail server provides two techniques for outgoing emails including HTTP API and SMTP. You can easily use HTTP API for integration with web apps. You can also use an SMTP server for integration with existing applications and systems.

Incoming Emails: Incoming mail can be forwarded to HTTP endpoint, SMTP server, and other email addresses using the postal mail server.

Spam and Virus Checking: SpamAssassin and ClamAV can be integrated with Postal to automatically scan incoming and outgoing messages as they pass through mail servers. This feature is also turned off by default.

Click and Open Tracking: Email openings and clicks can be tracked with Postal. Postal will scan your outgoing messages and replace any links with a new link that travels through your Postal web server. When the user clicks the link, Postal records the action and instantly redirects them to the original URL. However, this is not activated by default.

IP Pools: Postal allows you to send messages from a variety of IP addresses. This allows you to assign multiple IP addresses to different mail servers or send from different IPs depending on the sender or recipient addresses.

Postal Installation

Follow the below step-by-step guide to install the Postal mail server software on Ubuntu 18.04.

  • First, you need to connect your server vis SSH. Run the following command to update system with the latest available packages.
sudo apt-get update

Install MariaDB Database Server

  • Run the command to install MariaDB.
sudo apt install mariadb-server libmysqlclient-dev
  • Once you done with the installation. Now, you need to secure it by running the below command.
  • Next, it will ask you couple of questions as shown below. You need to answer all the questions.
Enter current password for root (enter for none):
Set root password? [Y/n]: N
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y
  • Connect to the MariaDB server with the following command.
mysql -u root -p
  • Create a database for the Postal.
CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
  • Next, create a database user called “postaluser” with new password.
CREATE USER 'postaluser'@'localhost' IDENTIFIED BY 'new_password_here';
  • After that, grant the user full access to the “postaluser" database.
GRANT ALL ON postal.* TO 'postaluser'@'localhost' WITH GRANT OPTION;
  • Next, flush the privileges and exit from the MariaDB shell with the following command.

Install Ruby

  • First, add third-party PPA to install Ruby. Run the following commands.
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
  • Update Ubuntu packages.
sudo apt update
  • Install Ruby by running the below command.
sudo apt install ruby2.3 ruby2.3-dev build-essential

Install RabbitMQ

  • Erlang is required to install RabbitMQ so, you need to install it as well. Add Erlang repository key to Ubuntu with the below command.
wget -O- | sudo apt-key add -
  • Next, add the Erlang repository with the following command.
echo "deb bionic contrib" | sudo tee /etc/apt/sources.list.d/erlang.list
  • Run the following commands to install Erlang.
sudo apt-get update
sudo apt-get install erlang
  • Once you are done with the Erlang installation, you can proceed to install RabbitMQ. Add RabbitMQ repository to the Ubuntu.
sudo sh -c 'echo "deb $(lsb_release -sc) main" >> /etc/apt/sources.list.d/rabbitmq.list'
  • Add the RabbitMQ GPG key with the following command.
wget -O- | sudo apt-key add -
wget -O- | sudo apt-key add -
  • Run the commands below to install RabbitMQ package.
sudo apt update
sudo apt install rabbitmq-server
  • Run below command to enable RabbitMQ, so it always start when the system boot.
sudo systemctl enable rabbitmq-server
  • Next, you will need to create RabbitMQ vhost and user for postal. Run the following command to it.
sudo rabbitmqctl add_vhost /postal
sudo rabbitmqctl add_user postal type_password_here
sudo rabbitmqctl set_permissions -p /postal postal ".*" ".*" ".*"

Install Nodejs

  • Add Nodejs repository with the following command.
curl -sL | bash
  • Next, run the command below to install Nodejs.
sudo apt-get install nodejs

Install Postal Mail Server

  • First, you need to create a user for postal mail server. Create it with the following command.
sudo useradd -r -m -d /opt/postal -s /bin/bash postal
  • Next, allow ruby to listen on web ports.
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3
  • Install all the required gems with the following commands.
sudo gem install bundler
sudo gem install procodile
sudo gem install nokogiri -v '1.7.2'
  • Create a directory structure for the Postal.
sudo mkdir -p /opt/postal/app
  • Next, download the latest version of Postal.
sudo wget
  • Extract the downloaded file with the following command.
sudo tar xvf latest.tgz -C /opt/postal/app
  • Next, change ownership of postal directory.
sudo chown -R postal:postal /opt/postal
  • Create a symlink for Postal binary by running the below command.
sudo ln -s /opt/postal/app/bin/postal /usr/bin/postal
  • Install all the required dependencies.
sudo postal bundle /opt/postal/vendor/bundle
  • Run the command below to initialize Postal configurations.
sudo postal initialize-config
  • Next, run the following command to open Postal configuration file.
sudo nano /opt/postal/config/postal.yml
  • Make the changes indicated in bold and save the file.
  host: <strong></strong>
  # The protocol that requests to the management interface should happen on
  protocol: https

  # Specify the connection details for your MySQL database
  host: localhost
  username: postal
  password: <strong>password</strong>
  database: postal

  # Specify the connection details for your MySQL server that will be house the
  # message databases for mail servers.
  host: localhost
  username: postal
  password: <strong>password</strong>
  prefix: postal

  # Specify the connection details for your RabbitMQ server.
  username: postal
  password: <strong>password</strong>
  vhost: /postal
  # Specifies the DNS record that you have configured. Refer to the documentation at
  # for further
  # information about these.
    - <strong></strong>
  smtp_server_hostname: <strong></strong>
  spf_include: <strong></strong>
  return_path: <strong></strong>
  route_domain: <strong></strong>
  track_domain: <strong></strong>
  • Run command to initialize database.
sudo postal initialize
  • Create a admin user for Postal.
sudo postal make-user
  • Next, you will need to provide user account detail as show below.
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      :
First Name          : Admin
Last Name           : Postal
Initial Password:   : *********

User has been created with e-mail address
  • Finally, run the following command to start and check status of the Postal application.
sudo -u postal postal start
sudo -u postal postal status

Install Nginx

  • Run the command below to install Nginx web server.
sudo apt install nginx
  • Next, copy Postal Nginx config to use it as Virtual-host.
sudo cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default
  • Create a self-signed SSL certificate.
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 -node
  • After that, you will need to answer the questions.
  • Open the Nginx default virtual host file.
  • Change the value of server_name and save the file.
  • Finally, restart Nginx web server by running the below command.
sudo systemctl restart nginx


We’ve gone over the introduction and primary features of the Postal Mail Server in great depth. We’ve also included step-by-step instructions for setting up this mail transfer agent. Furthermore, we have given some insight into the setup. Setting up a postal mail server is a simple process. I hope that this article is indeed helpful in setting up and configuring a postal mail server for your business.

Finally, is in a consistent process of writing blog posts on further latest open source products. Therefore, stay in touch with this Transactional Email category for the latest updates.


You may find the following links relevant: