How To Build Free SMTP Server Setup with Postal (Step by Step Guide)

SMTPie
10 min readJun 23, 2020

--

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

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.

Setup the SMTP Server, Let’s Start!

Ok, So Let’s start the real work! but before, you need to know what is required.

Requirements to Setup SMTP Server.

In order to Build and Setup an SMTP Server, you will mainly need two things:

  1. A Domain name
  2. 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:

  • Godaddy.
  • Namecheap.
  • freenom.
  • Enom.
  • Google Domain.

Here in the course, I will be using Godaddy to get my domain, but you can use any other service if you want, all work in the same way, and if you need any help, I will be here

Got a Domain? Great!

Let’s continue.

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.

Anyway, In our case, we will be using the VPS Server for Building an SMTP server.

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:

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.

Port 25 is used to send emails

Here is a list of some companies that allows port 25 by default:

  1. Host wind.
  2. Contabo.
  3. Interserver.
  4. OVH.
  5. Digital Ocean*
  6. AWS (some accounts are blocked)

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.

So Choose your VPS company and let’s get one.

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

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.

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

We have several SMTP Software like PowerMTA, Postal, Exim, Postfix…

In this guide, we will be using Postal as our SMTP software (service). So Let’s start:

If you selected Contabo as your VPS provider, you will need to run the following command on your server before you start:

sudo apt-get install apt-transport-https

To Install Postal, simply run this command on your server:

curl https://raw.githubusercontent.com/atech/postal/master/script/install/ubuntu1604.sh | sh

Note (this is one command line, so copy all and paste in putty and press enter)

The Setup is fully automated you will not need to do anything except waiting for a couple of minutes for the installation to finish.

When it’t Done, it will show you a success message “Installation complete“

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! So Simple

Configure Postal SMTP

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.

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.

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 need to change this in the postal config file to match your domain name. How?

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

And Refresh your web page, you must see now that example.com was replaced by your domain and you can simply copy the SPF record to your DNS zone.

Very Nice!

Now our Server is ready for testing.

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 Free SMTP server!

Wow!

Now you may be wondering how to use this SMTP as a relay to send emails from any email marketing application.

The Answer is simply by creating “Credentials” inside Postal to connect and authenticate to our Free SMTP Server.

Create Postal Credentials to Relay Emails

To create credentials, simply click on Credentials, then Add new Credentials.

For the Type, Select SMTP.

You can also select API if you wanna connect to postal through the API or develop your own application that works with Postal. Read more about the API here.

Enter a User (Anything you want)

And the Key, is the password, you can keep it as “automatically generated“

And that’s it, you can now use these credentials in any email marketing application.

Relay a Test Email

Simple, Go to SMTPER.NET and enter your server details as follows:

  • SMTP Host: Your Server IP or Domain.
  • Port: 25 or 2525
  • Login: The User You entered in credentials.
  • Password: The User Password.

So, these are the credentials that you can use in any Email Sender Application.

That’s it! I hope everything was simple and clear. we finish setting up the Free SMTP Server!

If you have any problems, you can open your questions on H-asnwers.com

--

--

SMTPie

Hey.. I’m SMTPie and i will solve all your issue related to SMTP or email marketing.