LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Your own mail server with Virtualmin

lowendtutorial

In light of recent events, there’s been a lot of chatter about leaving free e-mail services in favor of self-hosted e-mail. With self-hosted e-mail you have the option to host your e-mail wherever you want it, either on a server at home or on a VPS.

There’s plenty of affordable options around to run your own mail server. I would personally recommend a Xen or KVM VPS for this, as with OpenVZ it is really easy for your provider to “snoop” on your e-mail. This is also possible with Xen or KVM, but it usually requires a reboot (which you will probably notice).

I’ve used a 512MB Xen VPS for this tutorial. I’ve used “this much” memory because I want to run clamd and SpamAssassin in RAM. The server also has 45GB of disk space, which is more than enough to run a couple of big mailboxes on. You could do with less RAM (though that would increase the CPU load and slow down mail processing) and far less disk space (depending on your needs), but with “my” specs, you’re on the safe side.

Installing Virtualmin

I’m using Virtualmin in this tutorial. The choice for Virtualmin is quite easy: it’s free, fast, stable and doesn’t invade your system (like, for example, cPanel does). Virtualmin may not have the prettiest UI out there, but it’s clean and it’s effective. You’ll only be using Virtualmin to create and administrate mailboxes. Other than that, you won’t need it.

Virtualmin has an open source (GPL) version and a commercial version. The commercial version has some “advanced” features not in the GPL version. I’ll be using the GPL version. This should run on most Linux distributions and FreeBSD.

So let’s install Virtualmin. I recommend a clean server for this,  to avoid any conflicts. On the server, run:

wget http://software.virtualmin.com/gpl/scripts/install.sh

Which will get the installer script. Next, make it executable:

chmod +x install.sh

And finally, run the installer:

sudo ./install.sh

Which should ask you for your sudo password and if you’re sure you’re running the installer on a suitable system:

mpkossen@leb001: ~_002

Next, it’s going to install a bunch of packages. Just sit back and relax. Get a cup of coffee or a beer. It could take anywhere from 5 tot 15 minutes (on average).

Once that is done, open a web browser and go to either your IP address or domain name on port 10000 with ‘https’ prepended:

https://192.0.2.1:10000

https://leb001.example.net:10000/

This should ask you to log in:

Login to Webmin - Mozilla Firefox_003

Use the username and password of your sudo user to log in. Once logged in, the post-installation wizard should appear:

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_004

Click ‘Next’. You will be asked whether to preload the virtualmin libraries or not and whether you want to run the email domain lookup server. I would recommend against the former, except if you have plenty of RAM. I would recommend turning on the domain lookup server for faster mail processing.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_006

In the next step you can enable the ClamAV mail scanner server. I would really recommend enabling this.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_007

The same applies to the SpamAssassin server filter in the next step. This one is easier on the memory than the ClamAV server or domain lookup server, so even in you choose not to enable those two, you should enable this one.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_008

We don’t need MySQL or PostgreSQL running and sucking up memory. So disable both.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_009

We don’t need bind, so tick the box to skip the resolvability check and leave the other fields the way they are.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_010

Passwords should never, ever be stored in plain text, so only store hashed passwords.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_011

Click ‘Next’ to go to the ‘System Information’ screen.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_012

Which should look like this (don’t mind the yellow warning, we’ll get to that):

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_013

You’ve now successfully installed Virtualmin! Let’s configure it and create a mailbox.

Configuring services and adding your first mailbox

First, we need to configure some services. Go to ‘System Settings’ in the left menu and then to ‘Features and Plugins’.  This is where we disable all services that are not related to serving e-mail. Untick all the boxes I have unticked in this screenshot:

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_017

When you click ‘Save’ you should return to the ‘System Information’ screen.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_018

In the left menu, under ‘System Settings’, click ‘Re-Check Configuration’. This should check several things of your installation and display an error is something is wrong.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_019

Let’s create a Virtual Server, so we can add a mailbox. Click ‘Create Virtual Server’ in the left menu:

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_020

Fill out the domain name for the server, which is the domain name you wish to receive e-mail for. Also pick a strong password. Click ‘Create Server’ to actually create the server:

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_021

Once your virtual server is up, let’s create a mailbox. Click ‘Edit Users’ in the left menu, which should open the user list:

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_022

Clicking ‘Add a user to this server’ opens the screen to create a new user. Because we disabled several features before, the user you’re going to create will only have an e-mail account. So, basically, you’re creating an e-mail account.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_023

Fill out the e-mail address field, a real name and a strong password. Click ‘Create’ to finish this. You should be returned to the user overview, where you see your newly-created user including the IMAP/POP3 login.

Virtualmin 4.02.gpl on leb001.quateria.net (Ubuntu Linux 12.04.3) - Mozilla Firefox_024

And that’s it! You’ve just created your own e-mail server and your first mailbox!

To add your mailbox to an e-mail client, like Mozilla Thunderbird, your details will be (from the example above):

  • Username: john.smith.example
  • Password: the one you picked
  • Mail server (IMAP/POP3/SMTP): the domain name/IP of the mail server

TLS is available but the certificate is self-signed, so you should accept the certificate to enable secure communication with the mail server.

The final step is to point you domain name’s DNS records to your newly created server, if you didn’t already. If your domain points to the server, point the MX record to your domain. If you’ve used a different domain for your server, point the MX record to that or the server IP. Once the DNS records have propagated, you should be receiving e-mail!

Final notes

This is one of the easiest ways to get a mail server running. You can improve your server by using a commercial SSL certificate (although, there is word those are not save from government eyes either) and install webmail software. Those are things for a future tutorial, however!

Your mail server also supports IMAP IDLE, which boils down to push for IMAP. This works especially well with K-9 Mail on an Android device or Mozilla Thunderbird (which both support IMAP IDLE). So, no loss leaving your free e-mail service here!

Up next week: Getting started with OpenVPN (tap)!

95 Comments

  1. tutu apk's avatar

    good tutorials, thanks for sharing man.

    September 1, 2016 @ 5:46 am | Reply
  2. Z4root apk's avatar

    This is really amazing and very informative tutorial thanks for sharing this one.

    November 17, 2016 @ 4:31 am | Reply
  3. techiosinfo's avatar

    Is this good for mac.I have mac and want to install this. This is good way.

    November 24, 2016 @ 3:39 pm | Reply
  4. download cinemabox apk's avatar

    Good post again and thanks.

    December 2, 2016 @ 5:51 pm | Reply
  5. virtual router's avatar

    Hi there, I use a small usb modem for my internet access and using a usb wifi adaptor and a virtual wifi router I was able to share my internet …

    December 7, 2016 @ 10:35 am | Reply
  6. Jio TV app's avatar

    nice post, thanks for reference. I will try it.

    January 16, 2017 @ 1:33 am | Reply
  7. terrariumtvs's avatar

    thanks for nice post

    February 17, 2017 @ 6:33 am | Reply
  8. jul6art's avatar

    nice post, could you explain the records with an exemple please? MX, A and AAAA. i’ve got trouble in my installation

    Big thank you

    April 6, 2017 @ 12:33 pm | Reply
  9. Tubemate 2.2.8's avatar

    Tubemate is a software to watch and download videos online on Youtube very quickly and conveniently. This application is provided completely free

    May 20, 2017 @ 7:36 am | Reply
  10. appnaz's avatar

    Hi bro, I used a small usb modem for my internet access and using a usb wifi adaptor and a virtual wifi router.I was able to share my internet …

    June 28, 2017 @ 9:49 am | Reply
  11. Downloadapk's avatar

    I cannot install. As you said it only takes about 5 mins or 15 mins but I even waited for 1 hour but it did not done.

    July 19, 2017 @ 12:02 am | Reply
  12. Justin's avatar

    Thanks for your sharing. It has useful information which benefits me a lot.

    July 19, 2017 @ 5:00 am | Reply
  13. Max's avatar

    Nice. I also have intention of installing Virtualmin. Your post hekp me a lot. Thanks for your sharing.

    July 19, 2017 @ 5:15 am | Reply
  14. appfileapk's avatar

    Nice, it is really informative, thanks a lot

    July 24, 2017 @ 6:12 am | Reply
  15. showbox for pc's avatar

    ice. I also have intention of installing Virtualmin. Your post hekp m. this post is really amazing thing you can get this more at showbox apk here.

    August 9, 2017 @ 8:37 am | Reply
  16. popcorn time apk download's avatar

    popcorn apk is also a best know app for streaming movie app get this here for free.

    August 9, 2017 @ 8:37 am | Reply
  17. showbox alternatives 2017's avatar

    chekc this out latets showbox alternatives that might helpful for you

    August 9, 2017 @ 8:38 am | Reply
  18. root explorer's avatar

    this is very nice post and i have enjoyed a lot.

    August 22, 2017 @ 4:41 am | Reply
  19. jio4gvoice's avatar

    great post. and i have the post bookmarked for the future reading.

    August 22, 2017 @ 4:42 am | Reply
  20. Mahjong Master's avatar

    I usually use a small USB modem for my internet access and using a USB wifi adapter and a virtual wifi router I was able to share my internet …This is a nice post, it is really informative, thanks for your sharing very much.

    September 19, 2017 @ 12:05 am | Reply
  21. Showbox's avatar

    On our varlet, you will obtain a detailed pathfinder to download ShowBox Apk for Android and former platforms and use it to maximise your day-by-day acid of amusement. At the closing of the day, you will deliver often more than what you bargained for with this app. Before we advance to our scout, withal, we want to payoff a look at the features that survive a standout servicing.

    November 8, 2017 @ 11:36 am | Reply
  22. Terrarium TV's avatar

    Thank you for sharing. I was looking for the info and finally found it here.

    November 22, 2017 @ 1:22 am | Reply
  23. z4root for android's avatar

    Thank you so much for sharing…

    December 5, 2017 @ 4:28 am | Reply
  24. Izzie's avatar
    Izzie:

    Always wanted to do this, thanks for such valuable information.

    March 22, 2018 @ 5:30 am | Reply
  25. Terrarium tv apk's avatar

    thanks for sharing the knowledge with us.

    September 2, 2018 @ 7:09 am | Reply
  26. tvzion app's avatar

    Thanks for sharing wonderful information with us. We glad we found article to gain the knowledge 🙂

    July 12, 2019 @ 4:50 am | Reply
  27. Cyberflix TV's avatar

    Great infor. Thanks for sharing that.

    January 7, 2020 @ 10:46 am | Reply
  28. Pinoybay Teleserye's avatar
    Pinoybay Teleserye:

    Fantastic tutorial.Thanks for sharing that.

    January 10, 2020 @ 5:14 am | Reply
  29. huui's avatar

    Good Post.

    May 6, 2020 @ 10:04 pm | Reply
  30. Archero Mod APK's avatar

    Hello your post is amazing and I like it so much it helps me to understand a lot of things which cover my curiosity.

    July 8, 2020 @ 11:44 pm | Reply
  31. Jio server updates's avatar

    Thanks for the post.

    September 16, 2020 @ 9:00 am | Reply
  32. Burnard's avatar

    good tutorial thank you.

    September 27, 2020 @ 7:08 am | Reply
  33. Cinema APK download's avatar

    Thanks for sharing that. This is something totally new to me.

    June 17, 2021 @ 3:47 am | Reply
  34. Jon Biloh's avatar

    Glad so many people have found this tutorial helpful.

    June 17, 2021 @ 10:07 am | Reply
  35. jio tv's avatar

    Thanks for your post

    September 28, 2021 @ 4:57 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *