Tag Archives: hMailServer

Automate hMailServer Setup

For a set of demo systems (running on Windows) I needed a local mail server. I have been using hMailServer for quite a while in such scenarios. It integrates nicely with Windows (runs as a service), has an administration GUI and overall a good reputation. What was different this time? Well, I simply wanted to do the setup in a fully automated (also referred to as unattended) fashion. This comprises the installation and all following configuration steps that I so far used to perform using the GUI.

Some research on the web revealed that automating the  installation itself is quite easy but several requests for doing the same with the configuration were unanswered. This is funny because hMailServer comes with a COM API that allows you to do pretty much everything you would normally do with the GUI. I did not want to emerge as a .Net developer from this and quickly found that VBS (Visual Basic Script) is probably the quickest way. Back in 1998 I had done some serious development with VBA (Visual Basic for Applications) and Access 97 which made things relatively easy. So here we go …

The installation is automated using the /verysilent command line switch, which will install

  • server and administration tools
  • in the default location (%PROGRAMFILES%\hMailServer)
  • using the embedded MS SQL database
  • with an empty password for administration access

If you want a custom location for the installation, you can add /DIR="c:\pathto\hmailserver".

Then you  have to run the VBS script (download here and rename to hmail-create-accounts.vbs) which will create the account. The syntax to call from a command line window (cmd.exe) is start hmail-create-accounts.vbs USERNAME PASSWORD DOMAINIf you need other things automated the script and the API documentation should make this sufficiently easy.

If you want to go one step further, simply put the hMailServer installable and the script into your own installer. I usually recommend NSIS (Nullsoft Scriptable Install System) and its Eclipse plugin for this. The latter provides a nice wizard, so you can have your individual setup.exe in a just a few minutes.