Postal installation is not very straightforward. The process is fairly complex. It’s because Postal needs several packages to be installed beforehand, it can be used. I have tried to make it as simple as possible.
Requirement for Postal SMTP server
- A domain name from Namecheap or Namesilo
- A VPS or cloud with a minimum of 4 GB RAM and 2 vCPU
- Operating System: Ubuntu 22.04 or Ubuntu 20.04
I am using Contabo for the purpose of demonstration.
In order to start with installation, you will need to connect to the server. If you are on you have to get an SSH client for this purpose. One such SSH client is Putty. But if you are on Linux or Mac, just open the terminal and type email@example.com where xx.x.x.xxx is your server IP address.
First of all switch to root user
After that update and upgrade your Ubuntu
apt update -y apt upgrade -y
Next set up the hostname. Replace “example.com” with your domain name.
hostnamectl set-hostname mail.example.com
Updating DNS records
Login to the domain registrar and create A record for mail.example.com
Now let’s begin with the installation.
Note: This is a new installation guide. If you are looking for an old installation guide scroll down.
Installing Docker and Docker-Compose
Recently postal team switched to docker mode to make installation easier for the end-users. Therefore we need to install Docker and Docker-Compose first. I already have discussed what is docker, docker-compose & installation steps in detail. Feel free to read the article to have a clear understanding of docker.
First of all, set a few packages to set up the Docker repository
sudo apt-get install ca-certificates curl gnupg lsb-release
Next, add Docker’s official GPG key.
sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Now, you can install the Docker repository using the following commands
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Next update the system software
sudo apt-get update -y
Finally, run the following command to install Docker Engine and containerd.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
First of all download the current stable release of Docker Compose:
curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
Next, update the permission to binary
sudo chmod +x /usr/local/bin/docker-compose
Also, create a symlink as well
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Finally, test the docker-compose installation
docker compose version
You will see the docker-compose version. If you see anything else this means something has gone wrong.
Installing Additional Prerequisites for Postal SMTP
After installation of Docker and Docker-compose, you need to install a few other packages like Git, MariaDB, RabbitMQ, etc.
So, let’s install them one by one.
First, install git and git curl
apt install git -y apt install git curl jq
Next clone the postal helper repository
git clone https://postalserver.io/start/install /opt/postal/install sudo ln -s /opt/postal/install/bin/postal /usr/bin/postal
Now, you can install MariaDB in the docker container
docker run -d \ --name postal-mariadb \ -p 127.0.0.1:3306:3306 \ --restart always \ -e MARIADB_DATABASE=postal \ -e MARIADB_ROOT_PASSWORD=postalpassword \ mariadb
RabbitMQ is necessary to process messages and distribute the loads
To install it, run the following commands
docker run -d \ --name postal-rabbitmq \ -p 127.0.0.1:5672:5672 \ --restart always \ -e RABBITMQ_DEFAULT_USER=postal \ -e RABBITMQ_DEFAULT_PASS=password \ -e RABBITMQ_DEFAULT_VHOST=postalvhost \ rabbitmq:3.8
Now we have installed all the prerequisite packages, it’s time to install Postal
The postal repository, you installed earlier, is capable of generating some configuration files to use
Run the following command.
postal bootstrap mail.example.com
The above command generates 3 files. Out of which postal.yml is of our interest.
You need to edit the postal.yml and make changes. But before that install an editor. I suggest installing nano.
apt install nano -y
Now to edit postal.yml run the following command
You will see output something like this
# The host that the management interface will be available on host: mail.example.com # The protocol that requests to the management interface should happen on protocol: https web_server: # Specify configuration for the Postal web server bind_address: 184.108.40.206 port: 5000 smtp_server: # Specify configuration to the Postal SMTP server port: 25 logging: # Specify options for the logging stdout: true main_db: # Specify the connection details for your MySQL database host: 127.0.0.1 username: root password: postalpassword database: postal message_db: # Specify the connection details for your MySQL server that will be house the # message databases for mail servers. host: 127.0.0.1 username: root password: postalpassword prefix: postal rabbitmq: # Specify connection details for your RabbitMQ server host: 127.0.0.1 username: postal password: password vhost: postalvhost dns: # Specify the DNS records 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: - mail.example.com smtp_server_hostname: mail.example.com spf_include: spf.mail.example.com return_path: rp.mail.example.com route_domain: routes.mail.example.com track_domain: track.mail.example.com smtp: # Specify an SMTP server that can be used to send messages from the Postal management # system to users. You can configure this to use a Postal mail server once the # your installation has been set up. host: 127.0.0.1 port: 2525 username: # Complete when Postal is running and you can password: # generate the credentials within the interface. from_name: Postal from_address: firstname.lastname@example.org rails: # This is generated automatically by the config initialization. It should be a random # string unique to your installation. secret_key: b73a7e04571431c601d19a7688418eb395d059c1ada525dcfd337e978236be759e278367fb7c6773be625265d3d235ee98b4f8405957e4bbd1c4001f367442bf531843f690a1918626179bf297e31d5cd268c2f33339afd19b17ce901a3832bb9a8107f04bf1b702a4da16096141ed5c46cee3f739d3adabf89fa3cfd91f00cf
Cross-check your config file and then save and close the file with CTRL + X.
Initializing Database is super easy, just execute the following command and you will see database tables were getting created in the output.
After that, it’s time to build postal
You will be asked for the email id, name, and password of the admin user. Type the answer and then go to the next step.
Starting & Running Postal
Starting and running postal is also super easy. Just run the following command.
You can check the status of postal
This is a new feature added by the Postal team to install SSL automatically.
docker run -d \ --name postal-caddy \ --restart always \ --network host \ -v /opt/postal/config/Caddyfile:/etc/caddy/Caddyfile \ -v /opt/postal/caddy-data:/data \ caddy
Now you can go to
http://mail.yourdomain.com:5000 and log in using admin credentials. You will see the admin page something like this.
In, the next article we will learn to create an organization, domain management, SMTP creation, etc.
Installing Postal is no longer a complex procedure. Since postal is open source and freeware, it would be a good start.