In this Step by Step Guide, I will show you a full SMTP Server Configuration using Postal, the open-source SMTP software, and connect it to your email marketing application to send unlimited emails.
There are several methods to build SMTP servers, in this guide I will build the SMTP server using a free open source software called “Postal“.
Postal is a fully-featured open source mail delivery platform for incoming & outgoing e-mail and gives you all the tools and features needed to build a full mailing system for your business.
What is the SMTP Server?
I don’t like robotic definitions like Wikipedia, I love to make things simple. So…
Simply, SMTP is that thing that allows you to send emails over the internet.
SMTP stands for “Simple Mail Transfer Protocol”. It’s a Concept in Networking that you don’t have to worry about.
Just Know that SMTP is the technical thing that is responsible for delivering emails over the internet.
Let’s connect things, how this is related to email marketing?
I think it’s clear, but just in case, and As I explained in my Techincal Email Marketing guide, any Email marketing system consists of two parts:
- The sender: (SMTP service) this is the technical part. It allows you to send emails over the internet.
- The Management Application, where you can configure and manage your Email Lists, Marketing Campaigns, monitor and analyze results, manage your sending servers, and so on.
So we connect both together to get an Email Marketing System.

What do we mean by Sending Unlimited Emails?
When we say unlimited emails, this means that we can send unlimited emails from our server, there are no restrictions by companies or monthly plans to buy or so.
It’s your own server, u can send as much your server can handle in terms of resources. so when you have more (CPU and RAM), you can send more emails and so on.
SMTP Server Configuration
Requirements for smtp server configuration.
In order to Build and Setup an SMTP Server, you will mainly need two things:
- A Domain name
- VPS Server with port 25 opened.
1. Domain name
When you send emails, you will be sending from an email address like this one:
mail@h-educate.com
So in my case, “H-educate.com” is the domain name that I use to send my emails. so simply it’s required to have a domain name to use when you send emails from your SMTP server.
Usually, it’s your website domain name, except if you are working with cold emails, then it’s better to get and use another domain in case it got blacklisted, to keep your main business domain safe.
So if you don’t have a domain yet, go and get one NOW! in order to continue the Setup.
How to get a domain? simply you buy one! and it costs around 10$ per year, so it’s not that big deal!
We have a lot of DOMAIN REGISTRATION PROVIDERS where you can get a domain from like:
2. VPS Server with Port 25 opened.
The second thing you will need is a VPS server. a public server to install & Setup SMTP on.
What is a VPS server?
If you don’t know what is a VPS server, simply its a computer (a server) running in the cloud that you buy from a Web Hosting or Cloud Services company. And it’s publicly accessible with a Public IP.
A VPS can be used to host your websites with higher performance, can be used to run a machine 24/7 in the cloud to do any task you want.
Note: If you are interested in learning how to host your own websites on a VPS server, you can
Anyway, In our case, we will be using the VPS Server for smtp server configuration.
Port 25 open??
I mentioned that the VPS must have port 25 opened, what does this mean?
I don’t want to bother your head within deal technical stuff but in short. Any network service or software uses a certain port to communicate over the internet or network. Examples:
- Connecting remotely to another Windows Machine using RDP software works over port 3389.
- SQL database systems like MYSQL on our computer works over port 3306.
- Connecting to a Linux machine remotely to manage it with SSH, uses port 22.
- When you surf the web and open websites, we use port 80. and so on.
By default, all servers and computers have a firewall running which blocks all ports except the ones you want. so In order to use a certain service, we need to open that port in the firewall.
What you have to know also, that ports can be blocked and opened in two ways, incoming and outgoing, the following diagram will make things clearer:

I recommend you to watch my free course “Amazon EC2 for Digital Marketers” you will understand all these concepts in less than an hour.
So, in our case, we are building an SMTP server, and the SMTP software or protocol communicates over port 25. so we need to have port 25 opened.
So when you get a VPS server, just make sure that the company allows Port 25 an don’t block it, because some companies do this to protect from spammers.

Here is a list of some companies that allows port 25 by default:
- Host wind.
- Contabo.
- Interserver**
- OVH.
- Digital Ocean*
- AWS (some accounts are blocked)
*Digital Ocean Sometimes block some accounts and restrict port 25, but in general they allow all ports.
**Interserver open port 25 if you buy a spam filter service from them. Contact them first.
Are there any other Companies?? yes, simply you can contact the support of any company you want and ask if they block any ports by default. if not, then perfect, you can go with it.
Feel free to use any VPS company you want, It’s up to you!
You can also sign up on DigitalOcean through the coupon link below to get free 100$ to test everything free.
Or Start with Contabo which I think is the cheapest VPS service that you can use, I have 2 servers configured with Contabo.
After you select your VPS company, just create a VPS Server with the following specifications:
- Ubuntu 18 x64 as your operating system
- You can start with 1 CPU/2 GB RAM (And resize later).
Got your VPS? Great! Let’s continue.
VPS Server basic configuration.
Now we have our new Ubuntu VPS server, Let’s prepare it for our smtp server configuration.
Connect to your server, using an SSH client like putty or bitvise.
First, check your hostname:
hostname -f
If you don’t see a form of ANYTING.YOURDOMAIN.COM, then you need to change the hostname using the following command:
sudo hostname host.domain.tld
Where the host is anything you want. so in my case, my sample domain for this tutorial is xmailing.me, the command will look like this:
sudo hostname postal.xmailing.me
Map your domain name.
Now we have our VPS server and we set its name. Go to your Domain Provider and map your Domain to your VPS server. simply open DNS management zone and add a new A record like this:
host: server points: YOUR SERVER IP.

*server is in my case, you can choose whatever you want for your server name.
Done? Let’s continue.
Installation
SMTP Server Configration PreRequisites
Step 1: Install MariaDB Server
Just like any other application, Postal requires a database to save all the data and configuration inside it. To do this, we will install MariaDB using the below commands.
To do that, run the commands below.
sudo apt update
sudo apt install mariadb-server libmysqlclient-dev
After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
After that, run the commands below to secure the MariaDB server by creating a root password and disallowing remote root access.
sudo mysql_secure_installation
When prompted, answer the questions below:
- Socket password: N
- Enter current password for root (enter for none): Just press the Enter
- Set a root password? [Y/n]: Y
- New password: Enter your new password (create a secure one)
- Re-enter new password: Repeat your new password
- 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
Restart MariaDB Mysql service
To test if MariaDB is installed, type the command below to logon to MariaDB server
sudo mysql -u root -p
Then type the password you created above to login… if successful, you should see MariaDB welcome message like this:

Exit;
Installed DB? Great!
Step 2: Install Ruby and RabbitMQ
Postal needs Ruby, Erlang and RabbitMQ to work.
Install Ruby, Erlang and RabbitMQ packages on Ubuntu. These are required packages and are not available via Ubuntu default repositories.
To install the latest version of Ruby, you might need to do it from a third-party PPA. Below is how to add the PPA and install Ruby.
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
After that, run the commands below to update Ubuntu packages and install Ruby version 2.3.
sudo apt update
sudo apt install ruby2.3 ruby2.3-dev build-essential
Now that you have installed Ruby, continue below to install RabbitMQ. But first, Erlang is a prerequisite. Install Erlang.
wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add - echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list sudo apt-get update sudo apt-get install erlang sudo apt-get update
Now install RabbitMQ.
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
sudo apt-get install rabbitmq-server
After installing RabbitMQ, the commands below can be used to stop, start and enable RabbitMQ service to always start up when the server boots.
sudo systemctl stop rabbitmq-server sudo systemctl start rabbitmq-server sudo systemctl enable rabbitmq-server
Now it is time to configure RabbitMQ by running below commands.
sudo rabbitmqctl add_vhost /postal
sudo rabbitmqctl add_user postal p0stalpassw0rd
sudo rabbitmqctl set_permissions -p /postal postal "." "." ".*"
Install Node.js & Git
Node JS and GIT are required to run postal properly. Install them using below command.
sudo apt install nodejs sudo apt install git
SMTP Server Installation
Now all that the prerequisites are installed, it is time for smtp server configuration and installation.
Step 1: Create Database
sudo mysql -u root -p
CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
Next, create a database user called postal with new password
CREATE USER 'postal'@'127.0.0.1' IDENTIFIED BY 'p0stalpassw0rd';
After that, grant the user full access to the postal user database.
GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1`
IDENTIFIED BY "p0stalpassw0rd";
GRANT ALL PRIVILEGES ON `postal-%` . * to `postal`@`127.0.0.1` IDENTIFIED BY "p0stalpassw0rd";
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Step 2: Install Postal Mail Server
Now that your server has everything needed to run Postal Mail Server, continue below to get it installed and configured.
First, create a service account for Postal Mail Server
sudo useradd -r -m -d /opt/postal -s /bin/bash postal
Then, allow Ruby to listen to web calls by running the commands below:
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3
Next, installed required packages.
sudo gem install bundler
sudo gem install procodile
sudo gem install nokogiri -v '1.7.2'
Furthermore, create Postal Mail Server directory, download the latest version and extract it into the directory, then give Postal user access.
sudo mkdir -p /opt/postal/app
sudo wget https://postal.atech.media/packages/stable/latest.tgz
sudo tar xvf latest.tgz -C /opt/postal/app
sudo chown -R postal:postal /opt/postal
sudo ln -s /opt/postal/app/bin/postal /usr/bin/postal
Last, install Ruby dependencies and initialize Postal configurations.
postal bundle /opt/postal/vendor/bundle
postal initialize-config
postal initialize
Note: In case you face mimemagic locked error after running the first command, run the below commands then run the repeat above commands and continue:
cd /opt/postal/app
bundle update mimemagic
bundle install
cd ~
Step 3: Make Postal admin User
Now Let’s create a user so we can login and manage out Postal Server through the web interface. Simply run the following command:
postal make-user
And this command will ask you to Enter Your Name, Email, and password. so write it down and press Enter.
Postal is Installed!
Now run below command to start postal.
sudo -u postal postal start
Then run below command to check the status. All should be running.
sudo -u postal postal status
Step 4: NGINX
To manage Postal Mail Server via its web portal, you must install a web server. Run the commands below to install Nginx.
sudo apt install nginx
Then copy Postal Nginx config to use as its VirtualHost.
sudo cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default
Then create a self-signed SSL certificate to use with the portal.
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 -nodes
Answer the prompts on the screen.
Also, we need to edit the default file for NGINX using WINSCP as well.
go to: /etc/nginx/sites-available Directory. Then Open the default file.
Replace yourdomain.com with your domain name.
Then restart nginx.
sudo systemctl stop nginx
sudo systemctl start nginx
Postal SMTP Server Configuration
Now, Open your Internet browser, and navigate to your Server IP URL or Subdomain like this:
https://YOUR_SERVR_ADDRESS
You will notics an SSL warning, It’s ok just proceed as you see in the image below:

And then the Postal Login Screen will open, enter your email and password that you created during the setup to login.

And Now, you are inside Postal, click “Add Organization” to add one.
Then Click on Build Mail Server and enter the name, and set it to live mode

So Simple.
Edit Postal config file.
To Edit the Postal Configuration File, we will need to connect to our server using a File manager to make things easy.
So, You can Use WinSCP, a free remote file manager, to connect and edit the files on the server.
Open WinSCP, and Connect to your server using the root credentials. and go to: /opt/postal/config Directory. Then Open the postal.yml file.

Then, right-click and edit the file.

As you can see, just change the example domain with your domain name.
After that, you need to restart postal for the configuration to take effect.
So run this command on your server:
postal restart
Postal Domain Configuration
Now, Click On Domains to add you domain name into Postal

Enter your Domain name that you want to use to send emails, and Click Create Domain.
Then, Postal will show you the Domain page with the records that you need to configure.

So, What you need to do simply, is to copy these records and paste in your DNS Zone. and then your server will be ready to send emails! but what are SPF and DKIM?
Dkim (DomainKeys Identified Mail) :
Let’s Start with DKIM, A DKIM record is also a text record in your DNS that holds a public authentication key. This key will be validated using a private key saved privately inside your server.
All emails will be signed, and this will avoid any alterations and protect your email originality, and this is very important for your server to archive high sending scores.
Watch this video for more info:https://www.youtube.com/embed/7PMmqKYPpec?feature=oembed
Setup Dkim For Postal
What’s nice about Postal, is that DKIM is already configured and the keys are generated, you just need to copy the DKIM record to your DNS Zone.

SPF (Sender Policy Framework):
An SPF record is a TXT record that is added to your Domain DNS Zone and allows you to set the mail servers that are allowed to send emails from your domain.
Messages sent from a server that isn’t included in the SPF record will be marked as spam or rejected.
As an example, you can’t send an email from your own server and set your sending email as “mail@google.com,” you can’t use google’s domain. It indicates that you are trying to spam.
In the same way, you can configure SPF and prevent anyone from using your domain to send emails, So setting SPF is very important when it comes to making your domain trusted by other mailing providers.
To set up SPF. Open your DNS zone in and add the following record:
v=spf1 a mx ip4:XXX.XXX.XXX.XXX -all
*Replace with your VPS server IP.
Now only your server can send emails from your domain.
If you noticed, Postal will give you an example SPF to copy, and it looks like this:
v=spf1 a mx include:spf.postal.example.com ~all
This is just an example domain, and you will notice it is already your domain since you changed it in the postal config file to match your domain name.
Finally! Send a Test Email
Postal has built-in functionality to test sending emails, simply click on Messages, then on Send Message to test out the Free SMTP server!
Wow!
Optional Smtp Server Configuration: Secure with a Free SSL.
SSL certificates are used within web servers to encrypt the traffic between the server and client, providing extra security for users accessing your application. Let’s Encrypt provides an easy way to obtain and install trusted certificates for free.
Connect to your Server using Putty SSH client. and Let’s Start!
Step 1 — Install the Let’s Encrypt Client
Let’s Encrypt certificates are fetched via client software running on your server. The official client is called Certbot.
Install Certbot by running this command:
apt -y install certbot
Certbot is now ready to be used.
Step 2 — Get the SSL Certificate
But, before we get an SSL Certificate, we need to stop nginx service since its using port 80 which certbot will use. so Let’s stop it temporarily by running the following comnad:
sudo systemctl stop nginx
Now let’s install the certificate, run the following command:
certbot certonly --standalone -d postal.xmailing.me
Replace “postal.xmailing.me” with your domain.
And follow the wizard. Then certbot will issue a certificate for your domain.
Step 3 — Configure the SSL Certificate
After we got the SSL certificate, we need to configure it in our server.
Let’s start the nginx service again:
sudo systemctl start nginx
Now, Open WinSCP again to edit some files on our server.
Connect to your server, and go to /etc/nginx/conf.d directory.
In this folder, create a new file and name it: “postal.xmailing.me.conf“
Replace “postal.xmailing.me” with your domain.
Then, Simply copy the following code and paste inside the file.
server { listen [::]:80; listen 0.0.0.0:80; server_name postal.xmailing.me; return 301 https://$host$request_uri; } server { listen [::]:443 ssl; listen 0.0.0.0:443 ssl; root /opt/postal/public; server_name postal.xmailing.me; ssl_certificate /etc/letsencrypt/live/postal.xmailing.me/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/postal.xmailing.me/privkey.pem; ssl_protocols TLSv1.2 TLSv1.1 TLSv1; ssl_prefer_server_ciphers on; ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA512:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:ECDH+AESGCM:ECDH+AES256:DH+AESGCM:DH+AES256:RSA+AESGCM:!aNULL:!eNULL:!LOW:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS; location / { client_max_body_size 50M; try_files $uri $uri/index.html $uri.html @puma; } location /app/assets { add_header Cache-Control max-age=3600; } location @puma { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_pass http://127.0.0.1:5000; } }
And save the file.
The last step is to restart and enable nginx again. Simply run the following command:
systemctl restart nginx
Then this command:
systemctl enable nginx
And Awesome, Now you can test your secure Postal website!
I hope you enjoyed this tutorial for smtp server configuration.
Good Luck!
I get a error after adding the unsupported repo’s
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package ruby2.3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Package ruby2.3-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘ruby2.3’ has no installation candidate
E: Package ‘ruby2.3-dev’ has no installation candidate
Please post technical questions on h-educate.com/forums.
Hi there,
How can I enable IP Pools?
I went on WinSCP and turned “false” to “true” on IP Pools and it kinda worked.
But when I put my Additional IPs on the IP Pool on the Postal server, the emails sent from the additional IPs get stuck in “Pending”,
Emails sent from the Main IP of the server get “Sent”, but from the additional IPs, it gets stuck in “Pending”…
What should I do??
Please, I Need Help!
Please post questions on h-educate.com/forums.
Hi there friend,
IP pools doesnt work form me,
I need help with Postal and IP Pools:
I resently installed Postal Mail Server with your Blog tutorial. I followed the full tutorial,
I Wanted to enable IP pools on Postal,
So I went on WinSCP and turned “false” into “true” on the IP pool option on Postal…
The IP pools was enabled and I put my Additional IPs in there,
I sent a couple of Emails, but the emails sent from Additional IPs was stuck in pending,
Emails sent from the Main Postal IP was marked as “Sent”, but the Emails sent from teh Additional IPs where marked as “Pending” and they are stuck there!
I configured the additional IPs correctly with correct Hostname and IP adress, but they still don’t work…
I don’t know what to do ??
Please, I need help!
Please post questions on h-educate.com/forums.
1) Issue desired no. of Additional IP
You can use Contabo or OVH for using Multiple Ips because digital ocean don’t provide multiple IPv4
2) Go to IP Pool section in Postal Interface
3) Create a new pool and Add additional IP
Enter additional IP and Hostname accordingly and name it
4) Now, Go to Organization > IPs
Check all the IPs want to assign to that Organization and Save
1st Method
5) Go to /etc/network/interfaces file in WinSCP
6) Copy the existing IP and Netmask details
Like:
iface eth0 inet static
address YourIP
netmask YourIP
7) Paste after Primary IP’s netmask and before Primary IP’s Gateway details.
2nd Method
1) Just run this command
Command:
ip addr add your_ip/20 broadcast broadcast_ip dev eth0 label eth0:1
Broadcast IP =?
CIDR ( /20 ) =?
Both can be found by running this command
Command:
ip addr
Output:
2) Copy Primary IP’s Broadcast and CIDR and paste with above command and execute
3) After doing this, Run This command to ping additional IP
Command:
ping your_ip -c 4
4) Configure this IP to the domain and add A record.
Host: @, mx, rp
Value: Your additional IP for Postal SMTP
how to install SSL for (for Mautic) apache-with-let-s-encrypt-on-ubuntu-18-04
Your bundle is locked to mimemagic (0.3.5), but that version could not be found in any of the sources listed in your Gemfile. If you haven’t
changed sources, that means the author of mimemagic (0.3.5) has removed it. You’ll need to update your bundle to a version other than
mimemagic (0.3.5) that hasn’t been removed in order to install.
We are aware of the issue and waiting postal community to solve.
How can I connect this smtp to my email application
use the credentials tab in postal