Wednesday, March 25, 2009

Setting up local Mail (SMTP, POP3, IMAP) Server on XAMPP

While I was doing a PHP project on my localhost using XAMPP, i realised I needed a local mail server in order to send out mails from my own workstation for testing. To come to think of it, XAMPP provides MercuryMail - but it's user-unfriendly interface and low level support makes it very difficult to use.

Previously when I was on Windows XP Professional Edition, I was able to install IIS with SMTP server and configure as such for PHP on Apache (XAMPP) to send out mails via IIS SMTP mail server.

However when I shifted to Windows Vista Home Premium, i realised that IIS7 do not come with a SMTP mail server. So I tried finding an alternative mail server for my computer.

I remembered about a software called hMailServer which I used on a website server. It was quite easy to use and have great UI. So i decided to give it a try. I downloaded and installed hMailServer.

To configure your computer to properly send mail, you need to do the following:
1) When you first open hMailServer Administrator, you need to add a new domain.
2) Click on the "Add Domain ..." button at the Welcome page.
3) Under the domain text field, enter your computer's IP, in this case it should be
4) Click on the Save button.
5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
6) Enter "localhost" in the localhost name field.
7) Click on the Save button.

It should then be able to send mail.

If you need to send mail using a FROM addressee of another computer, you need to allow deliveries from External to External accounts. To do that, follow these steps:
1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of
2) Check the Allow Deliveries from External to External accounts checkbox.
3) Save settings using Save button.

Now you should be able to send email from your PHP project using mail() function or your ASP.NET application via your own computer's SMTP mail server.

UPDATE - 1st September 09
I was working with local application to send mail when I debugged that Windows Live Hotmail (the email from Microsoft) has denied all emails coming from dynamic IPs (which most residential computers are using). So this means that emails from your localhost cannot be sent to Hotmail accounts (e.g., ...). A workaround for this is for you have a Gmail account, and follow the following steps:

1) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
2) Enter "" in the Remote Host name field.
3) Enter "465" as the port number
4) Check "Server requires authentication"
5) Enter your Google Mail address in the Username field
6) Enter your Google Mail password in the password field.
7) Check "Use SSL"

and save. it will relay to Google Mail and then be sent to the intended recipients. Take note that whatever you write in the From header will be replaced with your gmail address. eg. you wrote From:, it will be replaced by Google to For more about this see