How to Host Your Own Email Server (with CyberPanel)


Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, you will learn the process of hosting your own email server. We will be using the open-source hosting control panel CyberPanel as our email server. The reason for this choice is because CyberPanel makes it extremely easy to generate all the necessary DNS mail records like DKIM, MX, and PTR. This is something that typically requires a great deal of knowledge in order to prevent your emails from being marked as spam.

By the end of this tutorial, you will have a full-functioning and properly configured email server. Let’s get started.

Note #1: In this tutorial, I am using a Linode server running Ubuntu 20.04 LTS as my server and NameCheap as my domain name registrar for While you don’t have to use these services, the following examples will be specific to them, but the same concepts will apply wherever your hosting is and domain name resides.

Note #2: If you do choose to use Linode, email ports are disabled by default. Please follow the instructions here to enable email ports on your Linode server.

1. Stand Up a Server

Whether you use a Linode server like I do, or have a physical server in your home, you will need a server to host your email. While I am running Ubuntu 20.04 LTS on my email server, CyberPanel also supports Ubuntu 18.04 at the time of this writing.

Minimum systems requirements for CyberPanel are as follows:

  • 1 GB or above RAM
  • 10GB or above disk space

Take note of the external IP address of your server. You will need that in the next step. The IP address I will be using in this example is

2. Register Personal DNS Servers

What makes hosting an email server with CyberPanel so easy is the fact that CyberPanel manages all of your DNS mail records for you. In order for this to happen, we need to set up personal DNS servers with our registrar and then proceed to create a private nameserver.

To register personal DNS servers with NameCheap, access your domain name from your Domain List. Click on the Advanced DNS tab and add two standard nameservers of ns1 and ns2 with the IP address of your server.

Namecheap Personal DNS servers ns1 and ns2Pin

You will end up with two nameservers, both of which are associated with the same IP address.


Next, go to the Domain tab for your domain name. Under the Nameservers section, select Custom DNS and add the two nameservers that you just created.

NameCheap custom DNS nameserversPin

3. Install CyberPanel on Your Server

Log in to your server via SSH and install CyberPanel with the official installer script.

sh <(curl || wget -O -

During the installation, choose option 1 to install CyberPanel with OpenLiteSpeed and make sure you install Postfix which will act as our mail server. All other options in the installation are up to you.

CyberPanel command line installationPin

Here are the options I chose.

  • 1 – Install CyberPanel
  • 1 – Install CyberPanel with OpenLiteSpeed
  • Y – Full installation
  • N – Remote MySQL
  • Enter – Press Enter key to continue with latest version
  • s – Specify the admin password
  • n – Do you wish to install Memcached extension and backend?
  • n – Do you wish to install Redis extension and backend?
  • Y – Would you like to set up a WatchDog?

4. Email Server Setup

Now that CyberPanel is installed, we can set up the email server.

The CyberPanel hosting control panel runs on port 8090 by default. To access the dashboard, navigate to your IP address followed :8090. For example, since my IP address is, I will go to in a web browser.

At the login screen, enter admin for the username and the password that you created during installation.

CyberPanel hosting control panel login screen at port 8090Pin

Within the hosting control panel, there are three steps we need to take in order to set up our self-hosted mail server.

A. Create a Website Container

The easiest way to associate your domain name with CyberPanel is to create a website. Although it’s possible, you won’t be hosting any content on the website right now. From the perspective of CyberPanel, this website is more like a container for a website.

To create the website container, go to Websites -> Create Website.

Fill out the form with your domain name and make sure you check the DKIM Support box.

Create website with CyberPanel with DKIM support for an email serverPin

B. Create Nameservers

Remember how you registered personal DNS servers at the beginning of this tutorial? Now you must create these nameservers in CyberPanel.

To create nameservers in CyberPanel, navigate to DNS -> Create Nameserver.

Fill out the form with your nameservers from earlier and the IP address of your server.

Create nameservers in CyberPanelPin


C. Issue an SSL Certificate

In order to make our mail server secure and encrypted, you must install an SSL certificate. You can do this in one click with a free SSL certificate from Let’s Encrypt.

Go to SSL -> Mailserver SSL.

Select your domain name from the dropdown list and click on the Issue SSL button.

Issue an SSL certificate for Postfix mailserver in CyberPanelPin

At this point, it’s a good idea to check the status of your DNS settings. You can use a free website like UltraTools to look up your DNS settings. It may take some time for these changes to propagate across the internet (a few minutes to a couple days), so be patient before moving on to the next step.

5. Set Up Reverse DNS

In order for your mail server to work properly as far as DNS is concerned, it is extremely important to properly configure reverse DNS. Reverse DNS is exactly what you’d expect. Rather than associating a domain name with an IP address like is done with DNS, reverse DNS associates a domain name with an IP address.

To set up reverse DNS in Linode, click on the Networking tab. Under the IPv4 section, click the three dots associated with your IP address and click on Edit RDNS.

Edit reverse DNS for an IP address in LinodePin

In the resulting popup window, type in your domain name to associate your domain name with your IP address. In my case, I typed in

Linode edit RDNS settingsPin

It may take some time for your changes to propagate across the internet (a few minutes to a couple days). You can check the RDNS status with MXToolBox.

If you are not using Linode, you will need to define a DNS record of type PTR while also maps your IP address with your domain name.

6. Create an Email Address

Now the exciting part you’ve been waiting for! Create an email address in CyberPanel by going to Email -> Create Email.

Fill out the form, specifying your domain name, and choose an email address and password. In my case, I picked for my email address.

Create an email address in CyberPanelPin

7. Send and Receive a Test Email

You can access your email inbox by navigating to Email -> Access Webmail. The default email client is RainLoop.

Log in with the email credentials you just created to reveal your inbox.

RainLoop email login screenPin

Compose an email, and send it to a recipient of your choice. Within a few seconds, you will see your email pop up in the recipient’s inbox.

Respond to this email to test out the ability to receive emails.

Composing a message in RainLoopPin

As one final test, you can check to see if your email server is configured properly from the perspective of spam filters. To see if your mail server is configured properly as far as DNS mail records are concerned, you can use a free tool like Mail Tester. Simply send an email to the address, and within a few seconds, you will be given a spamyness score out of 10.

Use mail-tester to check spam email scorePin

A full video tutorial of hosting your own email server is available below. Please let me know in the comments of the video or in the comments section below if you have any questions. I’ll do my best to help you out.

YouTube video

Meet Tony

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

45 thoughts on “How to Host Your Own Email Server (with CyberPanel)”

  1. Hey Tony,
    I am loving the tutorial, I ended up using the Digital Ocean version and I use Cloudflare for a DNS (using the cyberpanel cloudflare sync).

    I cant get my mail server to work correctly, I have a site created and a mailserver. It looks to me like everything regaurding DKIM and other records are in the cloudflare DNS.

    When I go to login to the rainloop it says account cannot access and if I try to connect it to an external client it says it can not connect either.

    Do you know of any resources or perhaps can you point me in the right direction? Thanks!

  2. Hi Tony,

    Sent you a question on Youtube on a few issues I like to know before getting started. After I configure this smtp server up for email – can I use a mail client to send emails – like outlook, profitmailrr (which is like an autoresponder using their option to add my own smtp server) or software like “Super Email Sender”? Next, is there a tool that can verify spam prevention when it sends the email to a prospect – in other words with this server sending emails out to not go directing into their spam box? Or, would that be covered with what you did above in this video with the practice of sending emails out slowly per day, like 25 the first day, then 50 next, and 75 the following, etc? Would that solve that issue to warm up the server to other servers when receiving emails us this new smtp server. [Hope that question makes sense?]

    • Hi David. I haven’t personally connected this setup to an external mail client, but I would think its possible to do. Unfortunately I’m not familiar with any spam prevention tools or best practices.

    • Typically PTR records need to be defined by the owner of the IP address. In your case, this would be your internet service provider.

  3. thanks Tony. A couple of notes … Linode blocks all email ports by default so just before the step to test email you will need to lodge a support call with linode to open ports. It would help us noobs to mention that creating the DNS records that they are “A” type. The setting of IPV4 reverse proxy has changed slighly with Linode so you might want to update the location details of RDNS. Cheers

    • DKIM keys will be created when you select the “DKIM Support” checkbox in step 4a. However, as you point out Mike, you can also do this manually.

  4. PS : Please delete this….

    You comment system errors on “post Comment” saying failed capture (which it didnt offer) and then when you “Post Comment” a second time it works! FYI

  5. Hi Tony,

    Very nice tutorial.
    Please whats the sending limit fo this webmail?
    Can it work as an smtp cos i tried to use it on gamadyne, the port 587 is not connecting but the 465 is connectiing…

    Hope to read from you sir

  6. Hi Tony, this tutorial is gold. Keep it up! However, after following through to the test section, I sent to two separate Gmail accounts and did not see the test messages. Anything wrong? Thanks for the tutorial

  7. Excellent article, and well presented. But here, one of your mentioned tools for checking DNS records (ultratools DNS records checking link) is somehow not functional anymore. Here is another tool I would like to recommend from an authoritative website. That tool gives you the DNS records lookup of the top most used 12 DNS records. The link to that tool is
    You can add that tool as a replacement to ultratools DNS Lookup.

  8. Hi Tony

    I tried the tutorial with Digital ocean vps and Contabo vps.
    Configuration was smooth an easy.
    But when I try to send a test email it aways say, CAN’T SEND MESSAGE

    What might be the issue and how to fix it ?


  9. Hello! Thanks for your blog post.
    I have a question, how can i change the default url to rainloop? I have a customer and they dont like the default url with the port.

  10. if I’ve to set up emails for 2/ multiple domains, then Can I set those in the same cyber panel, by making 2 or multiple sites?

    Also, how can I change the location of mails saved on the server?
    can I attach additional disk volumes whenever needed?

  11. Hy Tony,
    Thanks for such nice tutorial. But i am unable to send emails from different website i.e in your example you had set up reverse dns for, and what if we have to send email from different( website hosted in same vps. What might be the configuration for so that it can send email to gmail accounts; In my case i can send emails to other email providers but the google rejects the email, although spamming rating is 10/10.

  12. hey toni,
    i brought linode and namecheap to setup email server as you.when i install cyberpanel it says error to port 25 and the emails i send through rain loop didnt do i open port 25

  13. Hi Tony. Everything works nice but when I add new dns records in the cyberpanel dns manager, they are not propagated. Even after 3 days.

    What can I do?

  14. I wanted something similar… I wanted a subdomain to point to another Zimbra mail server, because it’s working and I don’t want to use Rainloop…

  15. Hey,
    I followed the exact same instruction. Still my mails are getting delivered in spam. Any idea how to debug or fix?

  16. Hey,
    I followed the exact same instruction using vultr.
    but every time I try to sign to rainloop i get authentication error Any idea how to debug or fix?

  17. Hi tony,
    I changed vultr to linode and I’m facing a problem with opening email ports with them.
    i followed the step but they send me this message
    “We’ve reviewed your account and we are unable to lift the SMTP restrictions from your Linode(s) at this time.

    If you would like to request this again in the future, we ask that you wait until you have at least 3 months of positive billing history on this account.”
    can you please explain how you did that?

  18. Master, congratulations on the tutorial. Even I, who am Brazilian, managed to understand and make it work… but my question is different… I want to use a server outside CyberPanel, for example, Zimbra… I have already created the server and it is working but how do I put it on CyberPanel? It has unique public domain and IP… How would I do this?

  19. Hi, your tutorial is great but there is one problem. After I set RDNS and created email account, I can’t log in into webmail. It’s always authentication failed. Where did I wrong? Thanks!

  20. Tony,
    Thanks so much for the video. I am fairly experienced with Linux and I use Linode so this was perfect. Oddly I cannot send email but I can receive. the only address from which I can receive is the cyber panel address. Do you have any thoughts? Thanks,Andrew


Leave a Comment

The reCAPTCHA verification period has expired. Please reload the page.