This is a complete tutorial about setting up an SMTP server on CyberPanel for free. This is a Linux mail server that can be used to run free email marketing campaigns. You are able to send or receive unlimited emails using this mail server. The emails sent by this server are not going to the spam box, all reach the inbox.
Using this method, you are able to get a 10 out of 10 mail score in the mail tester. Follow the all steps correctly, to get the best result.
There are so many additional features of CyberPanel you need to consider than use of SMTP mail server.
- Unlimited website hosting on one Panel
- Lite Speed free cashing
- Quic transfer protocol
- One-click automatic Let’s Encrypt SSL
- Multiple PHP versions
- Build in DNS and SMTP Email servers
- Web-based command-line interface
- Mutiple WordPress hosting sites
- Google drive backup system and much more.
Pre-requirements for Mail Server
Before going to the actual process, you need to full fill these requirements. First, you have to get a top-level domain name such as .com .net .org, free domains are not suitable for SMTP servers.
If you want a top level domain for the CyberPanel and your website or SMTP Linux mail server, you can use these providers to get it.
Next, you should have a VPS to install the CyberPanel. The VPS provider should be allowed to open SMTP port 25. In this video, I use Oracle Cloud free VM instance as the VPS but there is no option to set reverse DNS. Then you are unable to get 10 scores with Oracle Cloud, you have to go with another VPS provider.
If you want a powerful premium cheap VPS server, check these providers.
Setup Linux Mail Server on Oracle Cloud
You can use any size of the server to install CyberPanel but select Ubuntu 20.04 as the Linux operating system. You may be able to connect to the server remotely using Putty or any SSH protocol. I use Oracle Cloud free VM instance to build this server.
So, I demonstrate, steps related to Oracle Cloud but all steps are the same the only platform is different. If you want 10 out of 10 mail-scored servers, get VPS from another provider.
In the Oracle Cloud dashboard, click the “Create VM Instance” button to enter this window. Here you can customize your VM instance. If you want you can change the instance name. Under “Image and Shapes”, click the “Edit” button to select the OS of the instance.
Then Click the “Change image button”, you will see the available list of Operation Systems. Select Canonical Ubuntu 20.04 as your OS, not the minimal version.
Under “Networking”, click the “Edit” button to change network type. Make sure you selected both “create new virtual cloud network” and “Create new public subnet”.
You have to pass SSH keys to the instance. It is very important to connect to the server using the terminal. Select the “Paste public key” option to add a key. You have to install the Putty App to generate an SSH key pair.
After the installation of the Putty app, open Puttygen to generate new SSH keys. Click the “Generate” button and move your cursor in this area. Select the whole public key and copy the key into the instance.
After that deploy the server by pressing the “Create” button. Save the “Private key” in a safe place, it is very important to connect to the server.
Add Firewall Rules to Open Ports
While deploying the server, let’s go to the firewall section to open essential ports for this server. You can see there is a link call subnet, right-click and open it in a new tab. Click on the subnet name, you can add all ports here.
In this section, you can add rules by clicking the “Add ingress rules” button at the corner. Enter this IP parameter (0.0.0.0/0) as the source that allows all IP ranges to connect CyberPanel through the internet
You have to add all these TCP CyberPanel ports as destinations.
- 8090 – CyberPanel
- 80, 443 – Web Server
- 21, 40110-40210 – FTP
- 25, 587, 465, 110, 143, 993 – Mail Service
- 53 – DNS service
You have to add another rule to open CyberPanel UDP ports as well. Enter the same IP (0.0.0.0/0) parameter as the source and enter these two destinations.
- 443 – Web Hosting Server
- 53 – DNS Service
I have forgotten to change the IP protocol TCP to UDP for the first time. Now I corrected the protocol for these two ports. Remember to change the protocol at the first entry, then you don’t have to worry.
After adding firewall rules, go back to the “Instant Details” page. Now this server is up and running.
Install CyberPanel Web-Based Control Panel
First, Open the Putty app that you installed earlier. It allows you to connect the VPS using the terminal remotely. Paste the external IP address of the server as the hostname.
Under SSH, click “Auth” to add the private key that you saved in the previous step. Go back to the “Session” tab and saved your session using any name that you preferred. It is helpful to connect the server again without entering the credentials.
Putty App open the terminal like this, you can proceed by typing “Ubuntu”.
Get the root access before the adding Swap file.
You have to enter this long command to add Swap space to the server.
This command adds a 5024 MB Swap file to the system, you can add more memory by changing the number. Swap space is a virtual memory that assists the RAM to get better performance. This process takes time, wait until it is finished.
sudo dd if=/dev/zero of=/mnt/swap.0 bs=5024 count=1048576 && sudo mkswap /mnt/swap.0 && echo "/mnt/swap.0 swap swap defaults 0 0" >> /etc/fstab && swapon /mnt/swap.0 && sudo swapon -s
You can check the available memory by typing this command. Swap file added to the system successfully.
Set the hostname for this server. It is important to host an SMTP server using the CyberPanel.
Use this command to set the hostname. Remember to replace the domain name with your domain. Only Subdomains can use as the hostnames, not the root domain.
hostnamectl set-hostname sub.yourdomain.com
You can check the hostname by typing this.
Oracle Cloud set up an IP table inside the VM instances. Enter this command to get access to the server through the internet.
iptables -P INPUT ACCEPT && iptables -P OUTPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -F
Update and Upgrade the list of packages in the system using this command.
sudo apt-get update && sudo apt-get upgrade
Before running the CyberPanel installation script, get super user access by typing this command.
sudo su -
Install CyberPanel now. It will ask few questions before the full installation.
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
Before running the CyberPanel installation script, get super user access by typing this command. Install CyberPanel now. It will ask few questions before the full installation.
Select option 1 to proceed with the installation. The free option is CyberPanel with Open Lite Speed. Type “Y” to proceed with the full installation.
It asks to set up a MySQL server at the remote site, we have to install it in the server. So, select type “N” for that.
Press “Enter” to proceed with the lasted version of the CyberPanel. You can set the password for the control panel.
There are 3 options, default password, random password or you can set your password.
I chose to set the password. Enter a password and confirm it by retyping.
I don’t want to install Memcached and Redis for this server.
Type capital “Y” to proceed with the setup. This installation takes a long time, wait until it is finished the installation.
I speed up the installation process. After the installation, all the information related to the server will be displayed. Copy these details to a notepad before restarting the server.
You can connect to the server by typing your Public IP address and the 8090 port.
https:<IP Address>:8090 Username: admin Password: 1234567 (or the password you set)
After restarting the server, IP table rules are applied again then you are unable to connect the CyberPanel through the internet. Connect to the server again by restarting the session or using the saved session. Get the root access again to continue.
Enter the IP table released command again. Now you can refresh the window, it will redirect to the login panel.
iptables -P INPUT ACCEPT && iptables -P OUTPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -F
Use “admin” as the username and previously set password to login into the dashboard.
Point out Domain to CyberPanel
Now you finished the installation of the CyberPanel on your server. The Domain name should be pointed out to the external IP address of the server.
Go to the dashboard of your domain name provider and switch to the DNS management section. The platform may change from different providers but the process is the same.
You have to add “A” recode to the DNS section to point out the public IP address of the server. I use a subdomain to run this mail server that’s why I use this name. If you want to point out the root domain enter the “@” symbol here.
Enter the public IP address of the server as the source and save the settings.
This takes some time to propagate the domain name, you can proceed further.
After that login to the CyberPanel dashboard, click the website button to add our first website to this control panel. If you want, you can handle multiple websites on the same server. Select the “Create Website”, it will direct you to this form.
Set the select package “default” and select owner as “admin”. Enter your domain name or subdomain in this text box. Enter your working email address to receive important notifications. Select the highest PHP version for your site. It will comfortable with the latest versions of all Linux packages.
Under additional features, remember to select the DKIM support option. This is very important to keep high mail score in SMTP servers.
Create DNS Zone and Generate SSL Certificates
Next, we try to create a DNS zone inside the CyberPanel. In the main dashboard, click DNS and select “Create DNS Zone”. Enter your domain name or subdomain and after entering, click the “Create DNS Zone” button.
Now it is created successfully, go back to the dashboard.
To generate an SSL certificate to this server, click the “SSL” button in the dashboard. We have to generate an SSL certificate for both the mail server and the hostname. First, go to the mail server SSL and select the website that you want to generate the certificate. This takes some time to issue a new SSL certificate to the server.
Now it is done. next switch to the Hostname SSL using the sidebar navigation. All right, the server has a newly issued SSL certificate. This can cause to discount on the connection with the server due to the invalidation of the current certificate.
Simply, refresh the page and log in to the control panel again.
Create and Add Mail Server Certificates
Select “Email” to navigate email settings. At this time select “DKIM Manager” to generate DKIM keys for the SMTP server. Select the website and click the “Generate Now” button.
Sometimes this permission error will come. You can easily fix this reset the file permission of this path. First copy the path displayed here.
You have to reconnect to the server using Putty App. At this time, you can use the saved session to connect with entering the credentials.
Log in using “Ubuntu”. Get root access to the server.
sudo su -
Type this command to give permissions, remember to enter your own path that was copied from the error message.
sudo chmod 777 <PATH>
Now you can try to generate again by refreshing the browser window. You can see the DKIM certificate generated successfully.
Publishing the DKIM Record to DNS
You have to this DKIM certificate into the DNS records of the domain that you used to send emails. Public DKIM key contains 3 parts you have to copy one by one and add to the DNS recode.
Login to the DNS management section of your domain name provider. The platform may be different from different providers but all steps are the same. Follow all the steps carefully.
Add a new DNS record, that should be a TXT record. Add this as the name.
If you use the root domain you can leave this as it is but I used a subdomain then I have to add the subdomain part at the end.
Enter 3 parts of the public DKIM key to the value section. You can simply copy and paste them one by one from CyberPanel. After paste, all 3 parts of public DKIM, save the recode in the DNS section.
Setting up an SPF Record on DNS
Let’s add the second mail server record SPF. Add another DNS recode, this is also TXT recode. Enter this text as the value and remember to replace the public IP address from your own server IP.
v=spf1 a mx ip4:220.127.116.11 ?all
Add your domain or subdomain as the name of the record.
Adding the DMARC Record
The 3rd recode is the DMARC mail server recode. Again, you have to add TXT recode to the DNS. Enter this as the name of the record
Here also, if you use subdomain you have to add the subdomain part at the end.
Enter this text as the value and you don’t need to change that. It is the same for all servers.
Add MX Record on DNS for CyberPanel SMTP
The next and last record is the MX record. You have to select MX as the type of record on the DNS. If you use the root domain you can simply enter the “@” symbol as the name but I used a subdomain that why I enter the subdomain part.
As the value of the record, you have to enter the mail server hostname. In my case, it is the same as the subdomain I used. If you use the root domain it should be mail.your root domain.
The priority value should be set to 10 for CyberPanel. Now we are finished with creating SMTP mail server certificates.
Install Spam Assassin Service on CyberPanel
Spam assassin is a spam email filter that includes in the CyberPanel. This is optional but it is important to filter received emails. This setting can find under email settings. After navigating to spam assassin, click the “Install Now” button. It will install automatically and redirect you to the configuration page.
Check Mail Score and Send Emails
Now we finished the setup of the SMTP server. Let’s test the mail score and whether it goes to the inbox. I use the GMass SMTP mail sender and mail tester to check the score.
Enter your mail server name; in this video, I use mail server hostname as the subdomain that’s why the mail server is the same as the subdomain. If you use the root domain to install CyberPanel your mail server will be mail.your domain.
Enter previously created email for the “username” and “from email address”. Change the security protocol to TLS. Enter the password you previously created for this email account.
After that copy the received email address from the Mail Tester and enter into the GMass.
Click the “Test it” button to send the email. After few seconds, check the mail score on the mail tester. This server gets 8.8 out of 10 because Oracle Cloud free tier doesn’t allow setting up reverse DNS.
This 8.8 score is more than enough to send unspam emails. Let’s check how it works.
In the GMass SMTP mail sender, change the received email address to your personal email. Now send the test email again.
Login to your email account and see whether it reach your inbox without going to the spam folder. It is received to inbox safely.
Thank you for the reading. If you have any question, ask directly on MineX Tuts community Forum.