This tutorial of building an Email server will help to create a complete professional server that including
- Blog host (WordPress)
- Production Email inbox
- Free SSL Certificate
All in 5 simple steps using free tools.
We will ensure that our Email server is high-quality configured as a professional one that can send all emails to the recipient inbox folder, not the spam one.
Of course, to complete this tutorial, we need our domain name, and so you can select one from name.com or any Domain name hosting provider that you prefer.
We can build our Email server and the entire server services at the Home/Work Local server device.
But for the stable state purpose of the services, it's preferred to use cloud hosting services.
For this tutorial, I will use a Ubuntu 20.04LTS 2G Ram VPS (Virtual Private Server) at Linode.com is about 10USD/monthly.
I get a new XYZ domain name
petsarefamily.xyz is about 1USD/Year, and Creating a new VPS with public IP address
22.214.171.124, don't forget to change the domain name, IP address, and all required values with your own during the configuration steps.
1- Install Virtualmin The Open Source Server Control APP.
Virtualmin is a web-interface hosting server manager and control panel. It's an open-source and community support software.
Login To our server as root and start Installing Virtualmin as following
– Update the Ubuntu server by running the following commands
#apt update #apt updated
– Install Virtualmin by running the following commands
# wget https://software.virtualmin.com/gpl/scripts/install.sh # chmod +x install.sh # sh install.sh
You have to accept and continue the installation process and will need to enter your host FQDN.
And we will name it as
mail.petsarefamily.xyz [don't forget to replace petsarefamily.xyz with your domain name.]
▣□□ Phase 1 of 3: Setup [ERROR] Your system hostname localhost is not fully qualified. Please enter a fully qualified hostname (e.g.: host.example.com): mail.petsarefamily.xyz
And installation process will continue to configure and finish as below
[SUCCESS] Installation Complete! [SUCCESS] If there were no errors above, Virtualmin should be ready [SUCCESS] to configure at https://mail.petsarefamily.xyz:10000 (or https://126.96.36.199 192.168.192.57:10000). [SUCCESS] You'll receive a security warning in your browser on your first visit.
You can access your server now using your public IP address at port 10000. I can use my VPS information and access my Virtualmin at
https://188.8.131.52:10000 , and don't forget to replace the VPS Public IP address with yours.
For the first visit, when trying to log in to Virtualmin, you will need to accept the risk and add an exception to your server's private SSL certificate. Later we will create a public signed one.
Also, note that It's better to use the Firefox browser as it does not require more settings to ignore self-signed SSL checks.
The first thing to do at your Domain name hosting provider is to transfer your domain DNS records hosting to your server. Yes, we will host our DNS records.
OK, If you are on
name.com go to the domain details page and select
Nameserver Registration Account Transfer from the Advanced Section.
Then create ns1 and ns2 name server registers for our domain name.
And after creating the registers ns1 and ns2, we will enter them as NameServers in the Domain Details Pages, NameServers Section => Manage NameServers.
The same options will be available from any other Domain name hosting provider but under different labels and sections.
Now return to our Virtualmin control panel, and after login for the first time, it will run the post-installation wizard. We can accept all default values except for the MySQL server password, best have to change it to our chosen password, and for the DNS configuration wizard step, we will enter our ns1 and ns2 nameservers registers as primary:
ns1.petsarfamily.xyz and for the secondary:
With check the
Skip check for resolvability option.
After finishing this step, the next one will be the Create Virtual Host step
We will select the option of
Create server with domain: petsarefamily.xyz and make sure our value is our domain name and not the
And another option is to create our domain signed SSL with the Let's Encrypt certificate. We need to select it as Yes.
After this step, you may get interrupted because of changing of SSL certificate usage.
Note: If you missed the Post-installation wizard for any reason, you can run it again from sidebar menu select System Settings => then Press Re-Run Install Wizard as shown in the below image
After finishing the Post-installing wizard, we can check our server configuration by selecting the System Settings menu item from the sidebar menu, then Re-Check Configuration.
Now all the required packages are installed with basic Configuration.
And we will add more adjustments to ensure that our Email server works professionally and is ready for production.
2- Adjustment Email Server Settings And Configuration
The most critical settings to ensure all sent emails will reach the client or recipient inbox
1- Setup RDNS (Reverse DNS) with FQDN For Your Email Server
To setting the RDNS option in Linode VPS, you need to go to the network tab from the VPS details page => Then select Edit RDNS = > and enter your host FQDN:
You need to set
RDNS for both public IPv4 and Public IPv6 addresses.
If not on Linode, you can ask support to adjustment your VPS RDNS. I remember that digitalocean.com considers the
RDNS value as your VPS label.
2- Setting-UP SPF, DKIM, and DMARC Records For Your Email Server
It's a piece of cake settings while using Virtualmin.
SPF (Sender Policy Framework) record: is a DNS TXT record that tries to prevent phishing using your domain name by telling Email providers the correct server IP address that you will use to send email from or which MX servers you are permitted to send emails for you.
DKIM (DomainKeys Identified Mail) Record: is a DNS TXT record that gives any output email from your server a signature header, as a private key certificate that pairs with your domain public key certificate.
So It can expose to Email providers if the email received from you gets altered or if it comes from a none authenticated email server.
DMARC (Domain-based Message Authentication) Record: This is a DNS TXT record that tries to prevent malicious behavior by validating emails further by matching the validity of SPF and DKIM records.
From the left sidebar menu, select Server Configuration => DNS Options.
On the DNS Options page, make sure you select Yes for
SPF record enabled and Yes for
DMARC record enabled, then press save.
Enable DNS Records for IPv6:
From the left sidebar menu, select Server Configuration => Change IP ADDRESS.
Then in the New IPv6 Address section, select the
shared address options and then Press
From the left sidebar menu, select Email Settings => DomainKeys Identified Mail.
Then after finishing, press the same menu item again, and make sure to set
Signing of outgoing Mail Enabled to Yes, Then press Save.
3- Enable Let's Encrypt SSL Certificate
From the left sidebar menu, select Server Configuration => SSL Certificate => Let's Encrypt Tab.
Now all technical works are finished, and you still need to select your preferred Webmail client.
Just in one click, and from the same place, we can install the Webmail client and our WordPress blog website next click.
3- Select Email Server Client And Install Your WordPress Blog
From the left sidebar menu, select the Edit Virtual Server menu item => Enabled features,
MySQL database enabled , and press Save Virtual Server.
To Install the Webmail Client, select the Install Scripts menu item from the left sidebar menu.
Select RoundCube, then press
Show Install Option, Then press
Install Now, in the script option page.
Note that to access your inbox using RoundCube Webmail client, you will use the path
https://domain.com/roundcube, as the option of
Install sub-directory under
To control all Email accounts under your domain name virtual host, i.e.add new
firstname.lastname@example.org, modify, set specific quota, or delete. go to the left side menu and select Edit users to get into
Mail and FTP Users
Any way Virtualmin creates an automatic email user with the automatic name (the domain name) else if you change it.
If you missed your primary mail account password, you could get it by opening the Edit Virtual Server menu item from the sidebar menu, Then go to the Configurable setting tab, then Click on admin Icon beside the Administration password option
4- Setup Your Mail Client APP
To use your account with email clients on your mobile phone or desktop APP, you need to configure your client with the server information of the IMAP and SMTP as the following:
The server for imap and SMTP is: mail.domain.com For IMAP: Set [ SSL: Yes, and Port: 993] For SMTP: Set [SSL: Yes, Requires Authentication: Yes, Prot: 465] For Authentication: Use your Email and Passord
Hover we can Enable Email Client Autoconfiguration, from sidebar menu select Email Setting => Mail Client Configuration Then, select Yes for
Enable mail client autoconfiguration?, and then press Save.
This will help Autoconfig with all Email clients (Only use the email address and password) by adjusting your Email Server DNS settings.
5- Install Your Blog
To install your WordPress blog, from the left sidebar menu, select the Install Scripts menu item => Available Scripts Tab => Then select WordPress, Then press
If you want to access your WordPress directly under the main domain URL as
https://petsarefamily.xyz, you need to select
Install sub-directory under public_html At top level or choose your preferred blog path.
Select your language then, Continue.
After entering your website information, Press
Install WordPress then
Login, installation is simple that will be processed without asking you about database information. It will use the default values that passed to it from Virtualmin.