hMailServer for Outbound Only SMTP Server

If you ever needed to write program that sends email, most likely you’ll need a SMTP server. Here’s how you can configure one on a Windows box using hMailServer.

New Domain

After downloading and installing, you need to add a new domain to hMailServer. In my case I will not be using hMailServer to accept incoming email, hence I did not put the company’s email domain. Doing so will cause email to your colleague to be routed locally and likely fails.

So go ahead add a new domain, and just give it the local machine name (eg: devbox01.local). You have to pick a name that resembles an actual domain (with a dot and suffix), otherwise hMailServer will rejects it.

New Account

Once you’ve setup the domain, create a new account noreply@devbox01.local


Set a password, and that’s it you’re done. You can now use the SMTP server for outbound email

  • Username: noreply@devbox01.local
  • Password: whatever password you put in
  • SMTP host: devbox01
  • SMTP port: 25


Now what’s left to do is configuring firewall. If you program runs on the same box you might not need to do anything. However it’s good to check that no outside traffic from internet can connect to port 25 so no-one can abuse your SMTP server.

And as a last word of warning, do not assume all mails will be delivered. This SMTP setup is very basic. Depending on the content you send, SPF, reverse DNS entry, spam filtering of receipient, and gazillion other things, your email might not go through


About Apache Compression and Content-Length Header

Just resolved an interesting problem today, one of our code breaks because the response header set by the web server did not include Content-Length.

Spent quite a while investigating and turns out this is due to gzip compression. As seen below Content-Encoding is gzip and I think this causes Content-Length to be omitted.


Gzip compression can be disabled on apache via .htaccess config. In my case I disabled all compression to swf file by adding following configuration

<FilesMatch "\.swf$">
  SetEnv no-gzip 1

Testing TCP Firewall With Netcat

Simplest way to test if a port is open on firewall is through telnet, but problem with that is what if you don’t have anything listening? What if you’re preparing infrastructure for a new app-server deployment — telnet won’t work unless there’s something listening on the server.

With netcat you can create a simple listener that echoes whatever character passed to it. Netcat should be available on standard UNIX system via nc command.

If you want to test if port 1234 has been allowed through on firewall:

  1. On the server, run nc -l -p 1234. Netcat will wait incoming connection to port 1234.
  2. On the client, simply do telnet 1234 (assuming the server ip is

If the server is on Windows, there’s even a Windows version of Netcat available.

CentOS / RHEL NFS Share Network Folder Mounting


We are building a second web server with a hope of installing a load balancer soon. We came into a problem where we have to synchronize the file contents between multiple servers. The solution we’re opting is to install and mount a shared network folder (NFS) visible from both web servers. The shared folder lives on its own server (aka file system server).

It is assumed:

  1. The file system server host (Master) is
  2. The client is
  3. The folder to be shared on master is /var/www/vhosts
  4. The folder will be mounted to /mnt/nfs/var/www/vhosts on client

Creating a NFS Share on the File System Server

Perform these steps on the file system server (aka “Master”):

  1. Install nfs-utils and nfs-utils-lib package using yum:
    yum install nfs-utils nfs-utils-lib
    Use yum list installed to check if the packages are already installed
  2. Turn on nfs service so it automatically starts on boot
    chkconfig nfs on
    Use chkconfig --list to check status of all services
  3. Start rpcbind and nfs service
    service rpcbind start
    service nfs start
  4. Edit /etc/exports file and add following line at the end
    See here for explanation of the options
  5. Run following command to apply the changes
    exportfs -a

Mounting it on the Client

Following steps will mount the network folder permanently (folder will automatically re-mount on server reboot). Perform this on the client server:

  1. Similar to server, ensure nfs-utils and nfs-utils-lib are installed
    yum install nfs-utils nfs-utils-lib
  2. Create the directory that will hold the mount (mount point)
    mkdir -p /mnt/nfs/var/www/vhosts
  3. Edit /etc/fstab file and append following line /mnt/nfs/var/www/vhosts nfs defaults 0 0
  4. Run mount /mnt/nfs/var/www/vhosts to apply the mounting. Check if the mounting is successful using df -h

OS User on Master and Client

To ensure file system operations are consistent, consider propagating same OS user setup between the master and client. Note that although same username exists on both master and client they don’t necessarily have the same UID.

  • Checking uid and group of user jim:
    $ id jim
    uid=506(jim) gid=505(xyzco) groups=505(xyzco)

    (jim has uid 506 and belongs to group xyzco)
  • Adding a new user jim with uid 506
    useradd -u 506 jim
  • Adding jim to the group xyzco
    usermod -G xyzco jim
  • Setting / resetting password for jim
    passwd jim

Thanks To

Additional Reading

LogMeIn Hamachi Offline After Logging Out From RDP

I’ve noticed this behavior for a while, and did some searching over the internet. I found this post from hamachi forum about how to prevent hamachi going offline when RDP session is logged out’

So as a workaround you can log off your RDP without closing the session creating a shourtcut in your desktop directed to “%windir%\System32\tscon.exe RDP-Tcp#0 /dest:console” and run as administrator. This will log you off and leave the session open. Just saying.

So far this solution seem to work for me, need to figure out what will happen when another user logs in into the PC.

VirtualBox, Ubuntu and LAMP Stack

Came accross VirtualBox, a free & excellent virtual machine software. I decided to take it for a spin creating a Ubuntu virtual machine LAMP stack on it..

Here We Go

  1. Download and install VirtualBox
  2. Download latest Ubuntu iso installation file
  3. From VirtualBox create a new Virtual Machine. Select type: Linux and version: Ubuntu. On the next step you will be prompted with dvd drive containing the installaion disk, but instead just select the iso downloaded on step 2
  4. Go through the Ubuntu installation steps
  5. It’s also very helpful to install ssh server so you can ssh into your VM later on: sudo apt-get install openssh-server

Voila! You have ubuntu running on your Windows PC

Host and Guest

In virtualization realm, host indicates your physical PC (Windows 7 in my case), and guest is the virtual machine (Ubuntu). Most of virtual machine software documentation uses host and guest terminology heavily so make sure you’re familiar with it


This is where things get tricky. Virtual machine comes with virtual network adapters, and you have to do few configuration to setup connectivity between your virtual and physical adapters.

By default VirtualBox allows the guest machine to connect to the internet through NAT, so you can download data, browse internet etc. However if you want to run servers from the guest, it won’t be discoverable by the host or other PC in the host’s network immediately.

One approach to make them discoverable is by setting up port forwarding. You get here by going to networking section on the machine’s setting on Virtual Box


Note that setting port forwarding requires the port is actually free on your host machine. Hence I find it very useful to add an IP to your host’s network interface specifically for the VM so you don’t have port conflicts. In this example I added the IP on my interface:


The “AMP”

So there’s the “L – Linux” done. Now for the Apache, Mysql and Php, it can simply be done by using Ubuntu’s apt-get package manager:

  1. Open a terminal / SSH session to your Ubuntu machine
  2. Elevate into root using sudo su root
  3. apt-get install apache2
  4. apt-get install php5
  5. apt-get install mysql-server mysql-client

Few helpful notes:

  • Default doc root is /var/www
  • To start / stop apache: sudo service apache2 stopsudo service apache2 start
  • To start / stop mysql: sudo service mysql stop / sudo service mysql start

Benchmarking Web Page Load Time Using Apache AB Tool

Any apache httpd installation comes with ab tool on the bin folder. This handy tool can be used to perform benchmark testing:

ab -n 10 -c 2

The output you get is quite self-describing:

This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,

Benchmarking (be patient).....done

Server Software:        Apache
Server Hostname:
Server Port:            80

Document Path:          /
Document Length:        29320 bytes

Concurrency Level:      2
Time taken for tests:   4.524 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      297360 bytes
HTML transferred:       293200 bytes
Requests per second:    2.21 [#/sec] (mean)
Time per request:       904.890 [ms] (mean)
Time per request:       452.445 [ms] (mean, across all concurrent requests)
Transfer rate:          64.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.3      0       4
Processing:   806  887  90.4    852    1063
Waiting:      804  885  90.4    850    1061
Total:        806  887  91.3    852    1067

Percentage of the requests served within a certain time (ms)
  50%    852
  66%    888
  75%    918
  80%   1027
  90%   1067
  95%   1067
  98%   1067
  99%   1067
 100%   1067 (longest request)

Note that however I believe this tool will only request specified html page, not external resources associated with the page (no external images, javascript, css, etc.).

If you want to test https (SSL) page, make sure you have a version of Apache httpd with ssl support, and use abs instead.