In this Step by Step Guide, I will show you how to set up a Free SMTP server using Postal, the open source SMTP software, and connect it to your email marketing applicaiton to send Unlimited Emails*.

Also, you will find a video below Showing the setup if you feel something is unclear.

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.
So now I think It’s SUPER clear, we are going to learn how to build the first part of any email marketing system which the SMTP server.

VPS Server basic configuration.
Now we have our new Ubuntu VPS server, Let’s prepare it for out Setup.

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:

Domain: xmailing.me Type: MX 1 Points to: postal.xmailing.me
Domain: routes.postal.xmailing.me Type: MX 10 Points to: postal.xmailing.me

Domain: xmailing.me Type: A Points to: FIRST_SERVER_IP
Domain: xmailing.me Type: A Points to: NEXT_SERVER_IP

Domain: postal.xmailing.me Type: A Points to: FIRST_SERVER_IP
Domain: postal.xmailing.me Type: A Points to: NEXT_SERVER_IP

Domain: rp.postal.xmailing.me Type: A Points to: FIRST_SERVER_IP
Domain: rp.postal.xmailing.me Type: A Points to: NEXT_SERVER_IP

Domain: _dmarc.xmailing.me Type: DMARC Points to: v=DMARC1;p=none;sp=none;aspf=r;
Domain: postal._domainkey.rp.postal.xmailing.me Type: TXT Points to: NEXT_SERVER_IP

Use SSH command for generate DKIM:
sudo postal default-dkim-record

Domain: postal._domainkey.rp.postal.xmailing.me Type: TXT Points to: <dkim-record>

Domain: spf.postal.xmailing.me Type: SPF Points to: v=spf1 a mx ip4:FIRST_SERVER_IP ip4:NEXT_SERVER_IP ip6:IP6_SERVER_IP ~all

Domain: rp.postal.xmailing.me Type: SPF Points to: v=spf1 a mx include:spf.postal.xmailing.me ~all

Domain: postal.xmailing.me Type: AAAA Points to: IP6_SERVER_IP
Domain: rp.postal.xmailing.me Type: AAAA Points to: IP6_SERVER_IP

Setup Free SMTP Server
The VPS is ready, and we can start the installation process. So in order to setup SMTP Server on our VPS, we need to install an SMTP software.

Install Postal Free SMTP Software
Prerequisites – Postal runs entirely using containers which means to run Postal you’ll need some software to run these containers. We recommend using Docker for this purpose but you can use whatever software you wish.

To install docker, run below commands;

sudo apt-get update

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose --version

System utilties
There are a few system utilities that you need to have installed before you’ll be able to run some of the Postal commands.

sudo apt install git curl jq

Git & installation helper repository
Make sure you have git installed on the server by running below commands.

sudo git clone https://postalserver.io/start/install /opt/postal/install

sudo ln -s /opt/postal/install/bin/postal /usr/bin/postal

Maria DB
You can run MariaDB in a container, assuming you have Docker, using this command. Copy and paste this all in Putty.

sudo 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 install your postal database on MariaDB.

RabbitMQ
RabbitMQ is responsible for dispatching messages between different processes. As with MariaDB, there are numerous ways for you to install this. For this guide, we’re just going to run a single RabbitMQ worker. Copy all the below as one command and paste on putty.

sudo docker run -d \
--name postal-rabbitmq \
-p 127.0.0.1:5672:5672 \
--restart always \
-e RABBITMQ_DEFAULT_USER=postal \
-e RABBITMQ_DEFAULT_PASS=postal \
-e RABBITMQ_DEFAULT_VHOST=postal \
rabbitmq:3.8

Installation
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.

sudo postal bootstrap postal.YOURDOMAIN.COM

Initializing the database
Run the following commands to create the schema and then create your first admin user.

sudo postal initialize
sudo postal make-user

Running postal
You’re now ready to run Postal. You can do this by running:

sudo postal start

This will run a number of containers on your machine. You can use postal status to see details of these components.

Installing WEB Client
You can use any web client to run postal on your web, but in this guide, we are going to use Caddy. Install it with an SSL using below command.

sudo 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


Once this has started, Caddy will issue an SSL certificate for your domain and you’ll be able to immediately access the Postal web interface and login with the user you created in one of the previous steps.

Configure Postal SMTP
Now, Open your Internet browser, and navigate to your Server IP URL or Subdomain like this:

https://YOUR_SERVR_ADDRESS

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.

sudo nano /opt/postal/config/postal.yml

Postal domain change
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:

sudo postal stop

sudo postal start

Configure / ADD IP Address on Ubuntu 22.04

ip link

1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens3: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether fa:16:3e:1b:1d:ac brd ff:ff:ff:ff:ff:ff
altname enp0s3
3: docker0: mtu 1500 qdisc noqueue state UP mode DEFAULT group default
link/ether 02:42:f1:46:9b:19 brd ff:ff:ff:ff:ff:ff

sudo ip addr add FIRST_SERVER_IP dev ens3
sudo ip addr add NEXT_SERVER_IP dev ens3

We respect the work of other authors! This article is based on the tutorial:
https://h-educate.com/free-smtp-server-postal/


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *