Today in this article, we’ll be going to look at how to build Your Own Free SMTP Server. It was requested by a lot of users so now in this tutorial we will be building our own SMTP server.
What is SMTP Server?
Well, SMTP stands for Simple Mail Transfer Protocol” which is used for sending emails over the internet.
Let’s Build Your Own Free SMTP Server
OK so now let’s move on to the technicalities and start building our server.
Adding TXT Records in DNS
First of all, for setting up the server, we need to set some DNS records. To add the DNS records, log in to your Cloudflare account and navigate to the DNS tab.

The “A” in the “A” record stands for “address” and this is the most fundamental type of DNS record: it indicates the IP address of a given domain. If a website has an IPv6 address, it will instead use an “AAAA” record.
Now add the following records one by one:
A mail <your-server-ip> Auto Disable-Proxy
A <your-domain> <your-server-ip> Auto Disable-Proxy
A www <your-server-ip> Auto Disable-Proxy
After entering records, hit the Continue button.
Note: As you can see, proxy is enabled in the screenshot, but I disabled it later, so you must also disable it to get things to work.

Creating and Configuring Website Through CyberPanel
Now when the DNS records are set, go to the CyberPanel dashboard and navigate to Websites -> Create Website to create our website. Then enter the details in the input fields and click on Create Website button.

After the website is successfully created, then we need to issue SSL for our website so there won’t be an issue in the future. To do so, go to SSL -> Manage SSL.

Select the website for which you want to issue an SSL certificate from the dropdown and click on Issue SSL.

Now the SSL is issued, navigate to Websites -> List Websites to view and manage the website that we created.

When the new page is loaded, click on the Manage button of the website you created and want to manage.

Here at the top of the page, you can verify that the SSL is issued and will expire in 89 days.

Installing WordPress on a Website
Scroll down the current page till the end and there you will see the Application Installer category. Over there, click on WP + LSCache button to install WordPress on your site.

Enter the details in the input fields and click on Install Now to begin installing WP.

Installing WP Mail SMTP Plugin on a WordPress
After the successful installation of WordPress, type in the URL bar:
<your-domain>/wp-admin
Sign in to the WP dashboard for the next steps. You need to enter your credentials and hit Enter to log in.

Now navigate to Plugins -> Add New from the left bar to install the plugin.

Type the plugin name in the search bar “WP SMTP”. Hover your cursor over the first result and click on Install to install the plugin.

When the plugin is installed, you will see the Activate button on it. Click on that button to activate the plugin.

Click on the Let’s Get Started button on the wizard to continue.

On the next page, you will see the list of SMTPs but for now, click on Close and exit the Setup Wizard to exit the wizard. We’ll configure it later manually.
Adding TXT Records
Today, two of the most important uses for DNS TXT records are email spam prevention and domain ownership verification, although TXT records were not designed for these uses originally. The TXT record was originally intended as a place for human-readable notes.
We need to enter TXT records from the DNS of the domain we created. Now go to the CyberPanel and navigate to DNS -> Add/Delete Records to list all DNS records that we need to enter.
Choose the domain you created and it will list all records. Click on the TXT tab to view all TXT records.

We need to enter three types of TXT records:
- SPF Records: SPF TXT records list all the servers that are authorized to send email messages from a domain.
- DKIM Records: DKIM works by digitally signing each email using a public-private key pair. This helps verify that the email is actually from the domain it claims to be from. The public key is hosted in a TXT record associated with the domain.
- DMARC Records: A DMARC TXT record references the domain’s SPF and DKIM policies. It should be stored under the title _dmarc.example.com. with ‘example.com’ replaced with the actual domain name. The ‘value’ of the record is the domain’s DMARC policy
Common email authentication methods include Domain Keys Identified Mail (DKIM), Sender Policy Framework (SPF), and Domain-based Message Authentication, Reporting & Conformance (DMARC). By configuring these records, domain operators can make it more difficult for spammers to spoof their domains and can track attempts to do so.
Now when you know what these records mean, let’s enter them into our Cloudflare DNS.
First, you need to enter the SPF record in DNS with the name of your domain. The ‘@’ symbol will automatically add your domain name.

The second record we need to enter is the DMARC record with the name _dmarc
.

The remaining one is the DKIM record which needs to be added with the name of default._domainkey
.

You need to enter their values in the content section.
Now the TXT records are added, we need to add two more records.
Adding CNAME Record
The ‘canonical name’ (CNAME) record is used in lieu of an “A” record when a domain or subdomain is an alias of another domain. All CNAME records must point to a domain, never to an IP address.
In case if CNAME record isn’t added in your DNS, you need to put that one too.

We also need another A record in our DNS for the mail server to work without any issues. Here you need to enter your server IP address.

Note: Turn off the Proxy status so that it doesn’t cause any issue.
Now almost all records are entered except for one which we will enter later on.
Issuing SSL for Mail Server
Go to your CyberPanel dashboard and navigate to SSL -> MailServer SSL.

Select the domain from the dropdown and click on the Issue SSL button to issue SSL for our mail server.

Once the SSL is issued, we need to create an email account for this domain.
Creating Email Account
To create an email account, go to the Email -> Create Email to create the email for this domain.

Select the domain and fill in the input fields. The username can be any and you can also generate random password by clicking on Generate button. Once you fill in the input fields click on Create Email to create the email for the chosen domain.

When an email is created, go to Email -> List Emails to view all emails.

Now select the domain for which you created your email account. You might see an error message like in mine saying that SSL for email is not configured properly, you may get a Self-Signed error on mail clients such as Outlook and Thunderbird.
This issue is because of SSL but you don’t need to worry at all. Just click on the Fix Now button and CyberPanel will take care of everything and will fix the issue for you. Now the email is created successfully.
Adding an MX Record
Remember previously I said there is one record we need to enter, that’s the MX record.
A DNS ‘mail exchange’ (MX) record directs email to a mail server. The MX record indicates how email messages should be routed in accordance with the Simple Mail Transfer Protocol (SMTP, the standard protocol for all emails). Like CNAME records, an MX record must always point to another domain.
Now enter the MX record just like I showed in the screenshot with your domain.

The priority numbers before the domains for these MX records indicate preference; the lower ‘priority’ value is preferred.
Accessing RainLoop Webmail
Now it’s time to test the mail server that we have created. For that go to your CyberPanel dashboard and navigate to Email -> Access Webmail to continue.

Log in with your credentials. Remember you need to enter the email that you have created for a particular domain.

Now open a new tab and go to Mail-tester to check the email score. Copy that email displayed on the bar.

Head back to your Webmail tab and click on the New button to send an email for the score.

Paste the copied email address in the To: section and fill in other input fields and click Send to send the email.
Configuring WP Mail SMTP Plugin
Now go to your WP dashboard and navigate to WP Mail SMTP scroll down and click on Other SMTP.

Fill in all the input fields with the information shown in the screenshot and click on the Save Settings button.
Remember: You need to enter your mail domain in the SMTP Host field and account information for the email account that you created for the domain.

Now from the plugin general settings page, scroll down and do the following changes. You need to scroll down to the bottom of the page to save these settings too.

Sending a Test Mail
To verify that the server is working fine, you can send a test mail. You can do this by going to WP Mail SMTP -> Tools.
In the Send To field, enter the email address on which you want to send a test mail and click on Send Email button.

After you send the email, it will show you the result. If the email was sent successfully you will the Success page.

Congratulations! You have built your own free SMTP server on CyberPanel and can send emails.
How to Install and configure the OpenLiteSpeed server on Ubuntu?