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


gamers2000 said...

Google ;)

gamers2000 said...

gmail as SMTP server ftw :D

emptySoul said...

hi, i use mercuryMail where bundle with Xampp package. could you show me how to send email using mercurymail? i'ge tried bt get stuck till now...

thephpdeveloper said...

Hi emptySoul

I got fed up with mercuryMail. that's why I used hMailServer. I think apachefriends dropped mercuryMail in their latest bundle 1.7.3.

Sam Yong

Lintang said...

do I havo to setting the php.ini also in order to user hmailserver as my default SMTP gateway?

thephpdeveloper said...

Hi Lintang

I didn't set the php.ini. I am using xampp's default settings.

You might want to check your settings though:


piyush said...
This comment has been removed by the author.
piyush said...

i want to know that how can we check that i have configured pop3 with xampp... and how can i use pop3 (mercury) with xampp. i am working on after logic webmail lite

Olcay Ertaş said...

Hi I am trying to use hMailServer with Wamp server. I am trying to use gmail option but I am getting this error:

Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in C:\wamp\www\kariyersitem\register.php on line 163

I have checked address,it seems ok.

Can youı help me?

Olcay Ertaş said...

I have controlled the hMailServer logs and found this error line:


"SENT: 550 The address is not valid."

Do you have any idea what is the problem?

Olcay Ertaş said...

Setting sendmail_from to my eemail address in php.ini solved my problem.

Kamil Kiedrowski said...

Thanks for the tutorial! I'm glad I found this because I had a similar experience with mercuryMail and hMailServer couldn't have been easier to set up.

Genesis_15 said...

Mr. Olcay Ertaş, will you please help me on how to start up doing email server and send an email with my own contact form. I dont know where to start. I really want to learn it, i hope you'll share your knowledge with me. Hoping for a good response. Very much thanks! God Bless.

Olcay Ertaş said...

Genesis_15 sory to late answer. I have simply used mail() function and set sendmail_from option to my gmail address and it worked for me.

saxeli gvari said...

thanks very very much!!!

bienlac said...

hi thepho developer
can you also psost tutorial on IIS with SMTP, Im using WindowsXP Prof SP3.thanks

Nitin Golani said...

i am getting the following error after doing all what you said......
Warning: mail(): SMTP server response: 530 SMTP authentication is required. in C:\wamp\www\n\mail.php on line 1
what to do////////// please reply at

smrtboy said...
This comment has been removed by the author.
smrtboy said...

I configured hmailserver and wamp and squirrelmail in my pc, know i send mail from my hmailserver to ggmail acc then it wentoff, when i wanted to give reply to that mail its not going to the localhost i.e hmailserver.
So please rectify my problem

Jessica said...

thanks for sharing now i understand ...... i have mad a mistake...

honey said... using wamp server,and want to send an email message,but do not work,then i install hMAil server but i dnt know how i can use it......please help me to send a email msg through wamp server ,,,, i do settings in php.ini file but until its not working please tell me what can i do to send email message through wamp server

Zinavo Bangalore said...

Very useful post and nice information for beginners. Website Designing Company Bangalore | Web Development Company Bangalore