Windows Based Personal Mail Server

Wndows tips and tricks

Moderator: jkerr82508

User avatar
Posts: 587
Joined: 30 Dec 2013, 19:19

Windows Based Personal Mail Server

Postby Snorkasaurus » 24 Jul 2014, 04:30

Greetings Earthlings,

As mentioned in some previous posts, I think that "big mail" providers and "free email" providers are generally providing you mail-related services in order to profile users, and market at you. Clearly they are not coughing up terabytes of drive space, terabytes of bandwidth, and a parade of spam horrors just because they want to give you free email. I have had my own domain name since 2001 and have managed my own email essentially the whole time. It does require a little reading/learning but it doesn't have to be massively expensive... a P4 with a gig of memory is enough horsepower to run a small mail server for friends and family. Hopefully this description will help to encourage someone to take back control of their email related data... here's my story.

Back in the early 2000's there were fewer options available to someone wishing to run a personal mail server, and back then I thought that big mail providers discriminated against personal mail services (little did I know it would get much worse). I have tested various Windows based and Linux based mail solutions, and even tried Google Apps along the way. Anyone reading this is probably already aware that I think Google Apps is the wrong way to go for privacy reasons. I don't think that Linux based solutions are complete enough to be worth managing, they typically involve numerous separate applications for services (SMTP, IMAP, etc.) that should all be part of the core MTA application.

A PC capable of running XP is capable of being a mail server, the software listed below is not incredibly resource intensive. I was able to find one for CDN$50 and I spent CDN$10 to upgrade the memory to 2G.
Yes, my P4 is perfectly capable of running all of these (and a little more).

Actual Costs
Okay, so what does it really cost? Well here are the expenses you can expect to incur if you run your own mail server.
  • Internet Service: A mail server can be run on a home DSL or Cable connection and will increase your bandwidth somewhat. I run mine on a 12Mbit DSL connection that has a 300G per month bandwidth cap (traffic between 2am and 6am is not counted towards monthly limit) and this is plenty for my needs. The more external clients (reading mail) that you have, the more bandwidth you'll see being used up. If you have minimal speed or monthly cap you may need to increase it.
  • Internet Service II: I would strongly recommend a static IP address because dynamic ones will ultimately result in mail delivery delays when your address changes. My ISP charges CDN$4 per month for a static IP, your cost may vary. It is also important to verify that your ISP does not block any ports (incoming or outgoing) - the ones used by a typical mail server could likely be: 80 and 443 for webmail, 25, 465, and 587 for incoming mail, 110 and 995 for POP3, 143 and 993 for IMAP.
  • Domain Name: Your region may greatly impact which registrars you can buy a domain name from. I just renewed my most common .ca domain for a year at a cost of CDN$10.45... a .com shouldn't cost much more than that either. It is possible to find free "subdomain" providers who will provide names like but using those could pose some problems with being detected as spam (though they might be good for testing at first). Bottom line is to expect to spend less than US$20 a year on a domain name.
  • DNS Services: Some registrar's offer to sell you enhanced DNS services when you buy your domain name... don't bother, offers excellent DNS services for free.
  • The Server: As mentioned previously, I got my server for CDN$50, if you look around you should hopefully be able to find one for around that much... or piece one together from old parts lying around if you have a computer graveyard like me... or if you find yourself buying a new PC, keep the old one to act as your server.
  • Software: All of the software I am going to mention is free for non-commercial use (or better yet, open source).
  • Electricity: The server will have to run 24 hours a day, so expect it to add a little to your electricity bill. An old laptop would typically use less power, takes up less space, and is probably quieter than the average desktop PC. If you do use a desktop PC you can help reduce power use by removing non-essential expansion cards, disconnecting extra unnecessary case fans, disconnecting floppy and cdrom drives, and even disabling unused onboard devices like sound cards and LPT ports. Ultimately the actual cost shouldn't be terribly high, about the same as running a couple of old-school light bulbs all the time.
  • Sanity: Sooner or later something will probably go wrong... a dead drive or power supply, some misconfigured DNS setting, an Internet service outage, who knows. There is also some level of maintenance to running your own mail server... checking log files, Mom didn't get an email she has been expecting for more than ten seconds, Yahoo! doesn't think your mail is legitimate, etc. If you want something that requires no work at all, then you'll end up paying more in the long run (be it dollars, rupees or privacy), but it is everyone's choice to make.
The bottom line is that you can expect it to cost dozens of dollars a year, and if your family & friends are willing to cough up a few bucks in support of their privacy, then it should work out pretty good. Or better yet, get them to do non-monetary tasks for you like mow your lawn, fix your plumbing, or pick you up at the airport when your flight lands at midnight and there are no taxis in sight - any time you can leave the government tax hounds out of the picture it is a good thing.

So How Do I Build It?
Hold on, there are a few decisions you will want to make, and a few prerequistites before you start installing stuff:

If you do not plan to do any backups at all then you should stop reading now. You can do backups to a local drive (like an external USB drive) but I would STRONGLY recommend having remote copies of your data and it can be a pain swapping drives in and out. I have another PC (also a crappy XP box) at a remote location, which runs WinSCP to connect via SSH to my mail server, and it backs up all the necessary data though the encrypted tunnel at 1:00am every night. You could also do automated backups to a USB drive nightly and then weekly remote backups. There are lots of options, but I would recommend using at least some form of remote backup... which means adding FreeSSHd to your machine.
Domain Name
Find yourself a registrar that can provide the TLD that you want and do a bunch of searches to see if you can find a domain name that you like. When you find a name you like, shop around and see if you can find a registrar with better prices. As mentioned previously, you can use a DDNS service to test things out, but will want a real domain name if you are planning to stick with it.
Webmail and Other Client Access
If you wish to have webmail then you'll need to include Apache, PHP, and Roundcube (or similar applications) to provide that functionality, and if you want people to be able to access their mail with a client like Thunderbird, SeaMonkey, Claws, or their iPhone (not recommended) then you'll need to provide POP3 and/or IMAP4. Each of these decisions affects which applications you'll need to install on your server and which ports you'll need to open/forward on your router.
Plain Text or Encrypted Transmission
I would like to think that this is a no-brainer but I figure it should be said. If you are going to go to the trouble of setting up a mail server, then you may as well go to the trouble of encrypting transmissions where possible. NOTE: the transmission of mail between mail servers is usually plain text, and once a message leaves your mail server you have essentially no control over it - users who wish to truly control who can see their message will need to use endpoint encryption with emails. NOTE II: Client access to email needs to be authenticated (username & password) and this information is not something you want sent in plain text because it could potentially be read by the guy at the next table when you are at Starbucks, the NSA when your ISP sends it to them, or your buddy who gave you the WPA2 key for his wireless network while you were at his place.

Okay, go install the software
Throw in MySQL first, it is the largest and most resource intensive, and it is a dependency for hMailServer and Roundcube. I use version 5.1.71 because it was the best version I had in my collection of install files. There is a version 5.1.73 - but the thing to note is that if you go above the 5.1.x series you'll need to infect your machine with Microsoft .NET v4 (which I wouldn't recommend). The "Essentials" version (less than 40M) should be sufficient.

I like to create a C:\Apps directory so I can avoid Microsoft's "Program Files" failure that they still refuse to get rid of almost two decades later. Most of the software listed here shouldn't have any trouble with spaces in file/folder names, but there's no need to push your luck... just do a custom install and switch it to C:\Apps\MySQL. And while you're at it, switch the path to the data files to something much easier like C:\Apps\MySQL\Data - because the default path sucks.

When the install is done it will ask you if you would like to configure your new installation... do so, and take most of the defaults. When you get to the character set question you will likely want to change from the default Latin1 to UTF-8 which will potentially make interaction with other applications easier down the road.
Shortly after the character set question is the root password. Do choose a password that doesn't suck.

Next up, install hMailServer - the v5.4 series is current production release. Most of the defaults are reasonable but on the database selection screen you will want to change it to an external database. The built-in database works, and is fine for testing but don't run a production server on it.
As always, choose a reasonably strong password for your admin password (you need this to access the management GUI application) and cringe a little bit as it installs MS .NET v2.0 - This is what keeps me wishing I could find a decent Linux based mail solution. Meh, it ain't that big anyways (like .NET4). When done it'll ask you for the password and start the database wizard. Choose to create a new MySQL database and feed it information like this:
You can choose to make a separate user account if you are one of those folks who don't like to use the root account for anything. When asked if you want hMailServer to be dependent on any other service, select the MySQL service like this:
Now it is ready to setup the database but because you/we chose MySQL you'll probably get this error message:

Code: Select all

Starting task...
Please wait while creating database...
The MySQL client (libmysql.dll, 32 bit) could not be loaded.
hMailServer needs this file to be able to connect to MySQL.
The MySQL client needs to be manually copied to the hMailServer Bin directory. The file is not included in the hMailServer installation.
Path: C:\apps\hMailServer\Bin\libmysql.dll

So copy the libmysql.dll file from your MySQL\bin directory to your hMailServer\bin directory and hit next to finish up with your database setup. Let the installer open the hMailServer GUI (type in your password) and look around a bit. Create your domain and add in a user like this:
Now open up an email client like TBird or SeaMonkey and connect to your new server (I would suggest IMAP protocol rather than POP3) with the full email address as your username, and the password you used when you created the account. You should see an empty mailbox and you should maybe even have the ability to send yourself a test message to an external email address. Of course, it is far from finished, but it is the basic framework of a mail server.

To get inbound mail working you now need your domain name, and DNS setup. When you bought your domain name from your registrar you should have been asked for which DNS servers to use. If you want to use you should indicate the following DNS servers:

Code: Select all
and then head over to and make yourself an account. The interface there is pretty straightforward and the first thing you will want to do is add a domain (link is in the left margin on the management page). Once you have your domain added you need to create some records for your domain. Here is some basic info about DNS records:
  • A Record: points a name at an address (eg: ->
  • CNAME Record: points a name at another name (eg: ->
  • TXT Record: provides a textual reference (we'll use these later on)
  • MX Record: points to a mail server (should be pointing to an A record)
  • SOA Records and NS Records: don't mess with these, they control DNS for your domain
  • AAAA Records: called "Quad-A Records" are for IPv6 which you may care about down the road (or maybe sooner)
So to tell the world where your mail server is you need to setup an A Record (which points to your IP address) and an MX record which is specific to email. Head over to IP Chicken and write down your external IP address... If you use a router of some kind, this is the OUTSIDE address of your router (the PC's on your network probably have 192.168.x.y addresses which are only accessible to your internal network). Then head back to to create an A Record that points the name to your external IP address and an MX record that points to your A record. Here's an example of one of my domains.
Here are some tips to creating the records:
  • When typing in a name (like don't bother to type in the "" part, it will fill that in for you automagically.
  • The default TTL (Time To Live) of 24 hours is fine but you may want to shorten it up if you expect your IP address to change for any reason.
  • When setting up your MX record don't put anything for the "name" that way it will just default to "".
  • The priority of your MX records is only important if you have more than one. Many people use multiples of 5 for priority values so they can stick a few in the middle later if they need to.
Finally, you'll need to forward port 25 on your router to your internal mail server. Normally your router would stop all kinds of unwanted traffic from entering your internal network... in this case you are creating a rule that says "when email traffic arrives, forward it to my mail server". There are lots of different routers out there, and each one will have its own way of forwarding ports - since this post is already getting pretty long I'll just have to suggest that you search for "your router model" and "port forward". The ultimate goal here is to forward port 25 from your router to the new server. If you are able to figure out port forwarding on your router then send yourself a test email from a disposable gmail or hotmail account - if it works, you have a working email system.

But wait! There's more...
Okay, that was a lot to digest all at once, and frankly my fingers are tired of typing. If your mail server is working, that is awesome... but you still have lots to do - let's see if I can get the next part all typed up tomorrow.

Have fun eh,

User avatar
Posts: 9318
Joined: 14 Mar 2010, 16:34

Re: Windows Based Personal Mail Server

Postby viking60 » 24 Jul 2014, 10:07

Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

Return to “Windows”