This article provides a guide for how to install and run Postal email platform on Ubuntu VPS.
Step-by-Step Guide to Install and Run Postal Email Platform on Ubuntu VPS
Postal is an open-source mail server for sending and receiving emails, designed for businesses and developers. This guide outlines the step-by-step process to install and configure Postal on an Ubuntu VPS.
READ ALSO: Optimizing Your Hosting Experience: The Advantages of Ubuntu VPS Servers for Your Business
Prerequisites
Before you begin, ensure the following:
- Ubuntu VPS: Use a fresh installation of Ubuntu 20.04 or later.
- Minimum VPS Specifications:
- At least 4GB RAM.
- 2 vCPUs.
- 20GB disk space (more is better for logs and emails).
- Root Access: SSH access with a user that has sudo privileges.
- Domain and DNS: A domain name with DNS records configurable.
VPS Server Environment
For this guide, we will be using the following server environment:
- Plan: KVM-SSD-8
- CPU: 2 Core
- RAM: 8 GB ECC
- Disk: 128 GB SSD
- Network: 1Gbps
- 1 IPv4 (Public)
- /64 IPv6 (Public)
- Operating System: Ubuntu 22.04 LTS
- View more: Ubuntu VPS
How to Install and Run Postal Email Platform on Ubuntu VPS
To install and run Postal email platform on Ubuntu VPS, follow the steps provided:
-
-
Update and Upgrade the System
sudo apt update && sudo apt upgrade -y
This ensures your system is up to date and ready for installation.
-
Install Dependencies
Install necessary tools and libraries:
sudo apt install -y ca-certificates curl git jq
Install Git & installation helper repository:
git clone https://github.com/postalserver/install /opt/postal/install sudo ln -s /opt/postal/install/bin/postal /usr/bin/postal
-
Install MariaDB (10.6+)
Postal requires a database engine to store all email and other essential configuration data. You will need to provide credentials that allow full access to create and delete databases as well as having full access to any databases created. Postal will provision a database automatically for each mail server that you create.
Install MariaDB on your Ubuntu VPS:
sudo apt install mariadb-client-core-10.6
You can run MariaDB in a container, assuming you have Docker, using this command:
docker run -d \ --name postal-mariadb \ -p 127.0.0.1:3306:3306 \ --restart always \ -e MARIADB_DATABASE=postal \ -e MARIADB_ROOT_PASSWORD=postal \ mariadb
- This will run a MariaDB instance and have it listen on port 3306.
- Be sure to choose a secure password. You’ll need to put this in your Postal configuration when you install it so be sure to make a (secure) note of it.
-
Configuration
Before you can start Postal, you’ll need some configuration. The repository you cloned includes a tool to automatically generate some initial configuration files.
Run the command below and replace
postal.yourdomain.com
with the actual hostname you want to access your Postal web interface at. Make sure you have set up this domain with your DNS provider before continuing:postal bootstrap postal.yourdomain.com
This will generate three files in
/opt/postal/config
:postal.yml
is the main postal configuration filesigning.key
is the private key used to sign various things in PostalCaddyfile
is the configuration for the Caddy webserver
Once generated, you should open up
/opt/postal/config/postal.yml
and add all the appropriate values for your installation (database passwords etc…).Note that the docker setup mounts
/opt/postal/config
as/config
so any full directory paths mentioned inpostal.yml
will likely need to start with/config
and not/opt/postal/config
-
Initializing the Database
Run the following commands to initialize the database and create tables:
postal initialize postal make-user
-
Setup Caddy
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
Install Bundler (Ruby dependency manager):
gem install bundler
Run Postal setup:
postal bundle /opt/postal/app/vendor/bundle postal initialize-config
-
Configure DNS for Postal
Set up DNS records for your domain:
- A Record:
postal.example.com
→ VPS IP - MX Record:
example.com
→postal.example.com
- SPF Record:
v=spf1 a mx include:postal.example.com ~all
- DKIM Record: Add the DKIM public key (provided in Postal admin UI).
- Reverse DNS: Ensure the PTR record for your VPS IP resolves to
postal.example.com
.
- A Record:
-
Configure Postal
Edit the Postal configuration file:
nano /opt/postal/config/postal.yml
Set:
web.host
: The domain you set up (e.g.,postal.example.com
).dns.hostname
: The hostname for DNS records.smtp.listen_address
: Leave as127.0.0.1
or customize if needed.
Save and exit.
-
Start Postal
Run the following command to start Postal:
postal start
To check Postal status:
postal status
-
Access the Postal Web Interface
Open your browser and navigate to
http://postal.example.com
. Log in with the default admin credentials generated during setup. Update your password immediately.Enter your Postal credentials created during installation. Then access the postal platform.
-
Test Email Sending
- Log into the Postal web interface.
- Configure a mail server (e.g., SMTP endpoint).
- Test by sending emails.
-
Troubleshooting
- Logs: Check logs for errors:
postal log
- Firewall: Ensure required ports are open (e.g.,
80
,443
,25
,587
). - DNS: Verify DNS settings using tools like
dig
or online DNS checkers.
Conclusion
By following these steps, you’ll have a fully functional Postal Email Platform running on your Ubuntu VPS. Ensure you monitor system resources and apply updates regularly for optimal performance and security.