WampServer + hMailServer + SquirrelMail = Free Webmail for your intranet

After my last post about hMailServer, a free powerful mail server, one friend of mine have been ask me that hMailServer have the webmail support? The answer is yes and no.

NO - hMailServer don't have a built-in, ready-to-use webmail, but
YES- You can easily setup any webmail to works with hMailServer.

Today, I will show you how to setup SquirrelMail, a free webmail, to works with hMailServer for your intranet.

1. Create your domain for your intranet

Just open hMailServer Administrator interface, create a domain for your intranet email, for example: kafeblog.com If you do not know how to do it, please take a look at my last article about hMailServer, then comeback here when done.

Please note: With each domain you create in your hMailServer, please remember to add it into your hosts file, or your mail client cannot resolve it I'm assume that you name your domain: kafeblog.local

2. Create account for all your members

Again, another guided task, create 3-4 accounts for your testing purpose first, you can easily add more when the system running. For example we have:

  • khoinguyen@kafeblog.local
  • support@kafeblog.local

3. Download, unpack SquirrelMail and setup alias

SquirrelMail is a standards-based webmail package written in PHP. It includes built-in pure PHP support for the IMAP and SMTP protocols, and all pages render in pure HTML 4.0 (with no JavaScript required) for maximum compatibility across browsers. It has very few requirements and is very easy to configure and install. SquirrelMail has all the functionality you would want from an email client, including strong MIME support, address books, and folder manipulation.

  1. Firstly, download latest stable version of SquirrelMail from: SquirrelMail download page
  2. Unpack the downloaded file into a folder of your choice, I'm unpack it into: D:/code/squirrelmail Unpack SquirrelMail
    After unpack, you MUST have the folder structure as above
  3. Make sure your WampServer already running up, add an alias to your SquirrelMail folder Create alias for SquirrelMail in WampServer
    Click on the WampServer icon, Apache >> Alias directory >> Add an Alias
    Enter the alias for your SquirrelMail
    Once you run the script to add an alias, a command prompt will appears as above, enter your desired path for your webmail, I use 'mail' for mine
    Enter your path to SquirrelMail folder
    Enter the path where you unpack the SquirrelMail source code
  4. Go to http://localhost/mail/index.php, you will see the following ERROR message:
    ERROR: Config file "config/config.php" not found. You need to configure SquirrelMail before you can use it.

    OK, your alias is setup successful.

4. Configure your SquirrelMail

In your mail folder, you will found a config folder with a file named config_default.php. Rename the config_default.php to config.php

Modify a little bit (keep other variables as is):

$domain            = "localhost.local";
$smtpServerAddress = "localhost.local"; // your hMailServer address
$imapServerAddress = "localhost.local"; // your hMailServer address
$imap_server_type  = "hmailserver";
$data_dir          = "D:/webmail/data/";
$attachment_dir    = "D:/webmail/attach/";

Please remember to create the $data_dir and $attachment_dir, for security purpose, create it in a place web user cannot reach.

Note: On my test machine, when I set $smtpServerAddress and $imapServerAddress to localhost, it cannot connect to server, but localhost.local is ok

5. Congratulation! You're DONE!!

Okie, now open your browser, type in: http://localhost/mail/index.php

SquirrelMail will welcome you with their login page, fill in your email and password, Login. You can compose an e-mail to another test email, then login to that e-mail to check it. Everything is set.

hMailServer, WampServer and SquirrelMail and only 5 minutes, you have done to setting up a totally FREE webmail for your intranet.