In the Linux cPanel series, I reviewed Virtualmin, one of the best open-source cPanels for websites and email servers. Virtualmin is built on top of Webmin, another great, free & open source website control panel.
What’s great about Virtualmin is that it lets users straightforwardly create virtual servers. It lets managing multiple websites on one server and keeping all the websites separate from each other. So if one website is using PHP 7, the other could use any other version, or different technology can be used.
Virtualmin also sets up email services out of the box. All the user needs to do is point the incoming emails to the Virtualmin server.
In this article, I will explain how Virtualmin can be used to create and manage emails. There is no need to sign up for paid email services that cost a huge sum of money. Still, most of the premium services put a cap on bandwidth and email storage.
In Virtualmin, every email and its requirements, quota, and limitations are under user control. If you have clients, you can put a cap or provide unlimited resources without caps on bandwidth, email storage, or how many emails your clients can create.
Now without any further adieu, let’s get started.
How to install Virtualmin?
Virtualmin can easily be installed on almost all major Linux distributions. As part of the Linux cPanel series, I have reviewed Virtualmin and provided step-by-step instructions on installing it on Linux. Follow this guide for installation instructions.
Once the Virtualmin is installed, log in to the control panel using the system credentials. You can use your Linux username and password. By default, Virtualmin runs on port 10000. However, it is recommended to change the port for security purposes.
The first time login will start a setup wizard. It is important to carefully select options as it’ll craft Virtualmin depending on how you want to use it. Only select the services you need to save important system resources.
As in this article, we are setting up our email server to enable all the email services we need, such as SpamAssassin and Clam AV. Remember, all these services require system memory to run properly; it is advised only to run these services when the system calls for it. The wizard will ask how to run a specific service on the system.
SpamAssassin, as the name suggests, assassinates spammy emails. It scans all the emails and lands all the spammy emails in the spam box.
The Virtualmin post-installation wizard walks you through setting up SmapAssassin on your server. It consumes around 30M system memory, so based on the system resources, you can choose to run SpamAssassin or not. If SpamAssassin is not loaded in the memory, the email processing takes time, and you save around 30M system memory.
ClamAV is a free and open-source anti-virus for Linux operating systems. The Virtualmin post-installation wizard guides you through setting up ClamAV on your server.
ClamAV scans all the emails for any harmful links and attachments. It consumes around 100M RAM. If you choose to run the ClamAV scanner, it will consume 100M memory and faster email processing.
The rest of the wizard steps are simple, and I have discussed them in this article. If you still need any help, please let me know in the comment section below.
After setting up SpamAssassin and ClamAV, we are good to go.
Create Virtual Server
To create email accounts, we will need to create a virtual server. Click ‘Create Virtual Server’ from the sidebar. Fill in your domain, description, username, and administrative password. We will use this username and administrative password to log in to your email account.
The server configuration template and account plan is a handy way of monitoring and limiting users’ accounts in bulk. You can create server templates and Account plans and put users into those plans.
The next up, Advanced options. Here you can set up Contact email addresses, but the account in a custom group, add a prefix with email usernames and name the default database. You can leave all of it by default.
The next up is an important section, Enabled features. This is where administrators can disable or enable specific features on the user accounts. To make this email account use email features, check ‘Accept mail for the domain‘.
At the end are the IP Address and forwarding section. Here you can set up email forwarding, network interfaces, and IP address. If you want to set up email forwarding, just put the email address to forward all the emails. Leave the rest of the options as default.
Finally, click ‘Create Server‘. It’ll take a minute or two to create your first server. Once the server is created, you will see all the options to manage this virtual server in the sidebar.
Create email address
In Virtualmin, creating an email address means adding a new user account. Click the ‘Edit users’ option from the sidebar, and it’ll list all the existing users.
To create a new user, click ‘Add a user to this server. It will open the following window with all the useful options.
Enter the username, real name, and password. As you can see, the final email address would be [email protected].
In the Quota and home directory settings, you can set account limits and the user’s home directory. Leave the home directory option as default. You can change the quota amount. By default, it sets up each user with 50MB storage. You can change it to 500MB or 500GB as long as your server has that much storage, or you really want this user to have a huge amount of storage on your server.
In the ‘Email settings‘ section, you can add any additional email address you want this user to have. For example, if a user is a forum moderator, you can create their primary email address and additional emails such as [email protected].
Always scan each email for spam and viruses unless you want to see your inbox full of crappy emails that are throwing away bitcoins, selling drugs, and so on.
Email forwarding, automatic reply, and user permissions
The rest of the two sections are pretty straightforward. You can set up email forwarding, enable automatic reply, and set up user permissions. If you want to allow users to upload files using FTP clients like FileZilla, you can activate FTP access in user permissions sections.
Finally, click ‘Create‘ to create the user account.
After the user account is created, open Usermin. Usermin is another front of the Virtualmin that’s for clients.
By default, Usermin runs on port 20000. So visit ip_address:20000, and it’ll ask for the username and password.
Enter the credentials that you have just created, and voila!
And it is almost done. You should now be able to send emails perfectly. Try to send your first email from the new account.
Set up MX record to receive emails
At this point, you can only send emails. To receive emails, create an MX record using the domain’s DNS manager.
Log in to the service where you purchased your domain name. All domain providers have an easy-to-use DNS manager that we can use to point incoming requests to the hosting server. To point email addresses to the Virtualmin server, an MX record.
Since we can not point MX record to IP address, we will need to create an A record and MX record to this A record.
The A record can be ‘mailserver.domain.com’ pointing to the Virtualmin server IP.
Create an MX record and point it to ‘mailserver.domain.com’.
Once done, that’s it. The changes may take 30 minutes to reflect. Meanwhile, play around and grab a cup of coffee. After that, send a test from Gmail or ymail to your account, and it’ll work.
Sometimes DNS propagation takes more than 30 minutes. In this case, you may want to contact the domain provider for DNS manager-related support.
Hosting your own email server saves you a lot of money. Most of the services charge a huge amount of money per month and per user basis.
Virtualmin makes the entire process easier by providing GUI for everything. However, there are a few things to remember. If your IP address is masked by a cloud firewall such as Cloudflare and sucuri, creating an MX record may expose your origin IP address.
If you intend to hide the web server’s IP address behind a firewall, I recommend setting up an email server separate from the webserver.
For more information, please visit Virtualmin forums.
Hello, thank you for the article. My question is: is this default config using Postfix mail server? What mails server are this installation using?
Virtualmin can utilize multiple mail servers. Read more about their mail configuration here.
I can receive and send. But, cannot send to Gmail. I get the following message “…Our system has detected that this message does 550-5.7.1 not meet IPv6 sending guidelines regarding PTR records and 550-5.7.1 authentication….”. I think I need a reverse DNS or something.