Setting up a localhost mailserver

The other day I was looking at how to make a simple mail server work in my windows XAMPP installation.  This comes in useful if you’re testing an application that sends confirmation emails to registered users to confirm registration or to send a new password.

When I started I was getting errors like: SMTP server response: 550 Address not known here; and SMTP server response: 553 We do not relay non-local mail, sorry.

After hunting around a little on the interweb I didn’t really find any instructions for dummies like me.  So in the end, I just thought it through a little.  I first decided what my goal should be:
send an email from a localhost user to a localhost user.  I’m not worrying about sending emails to external email addresses, because my web host will handle that – I don’t need a fully functional email server.

So here are the steps I took:
Set up Mercury:
1) Turn on the Mercury email program from the XAMPP control panel (without this on you will get nowhere).
2) Click on the Admin button once Mercury has started to open its admin panel.  You’ll be presented with a mass of floating windows – just ignore those.
3) Select Configuration -> Manage local users… from the menu
4) Create new users.  Note: just create names with letters and numbers, if you type a name it doesn’t like, it won’t tell you why, it will just refuse to save the user.  So I created the usernames: marktest1 and marktest2

That’s Mercury set up, now you just need to test it.  To do this you need to add these new users to an email program like Mozilla Thunderbird or Outlook Express.  For testing things like this, I use Thunderbird Portable – I just find it convenient to have test emails like this handled seperately from real emails.

Set up Thunderbird:
1) Go to Tools -> Account Settings
2) Click on Add Account
3) Your email address is going to be something like marktest1@localhost   Note: the email address isn’t
4) Your Incoming server is simply: localhost
5) Click on Outgoing Server (SMTP)
6) Click Add
7) Again the Server name is going to be: localhost

Set up at least two accounts in Thunderbird, so you can test sending yourself an email.  Once you can send emails between your two new users, you should be able to send emails from your web applications.  Just remember to use @localhost email addresses.  You might need to check your email validation procedures accept this style of email address.

Below is a youTube video that goes over the steps I have outlined above.

Be Sociable, Share!
    This entry was posted in how to, IT, Websites and tagged , , . Bookmark the permalink.

    15 Responses to Setting up a localhost mailserver

    1. Jansie Blom says:

      Beautiful. thanks so much for this. works like a charm. i must add though, that i had to watch the vid. the slightest little mistake in email settings gives an error message.


    2. Thank you very much for the guide. It really help me. Thanks again ..

    3. Saurabh Bansal says:

      Thanks a ton!!! You solved my problem. Kudos!!

    4. madastro says:

      Hi, Thanks for the tutorial, I managed to do the same with XAMPP setup, but hit a little snag. I have a validation system in place so entering just mail@localhost would trigger an error. how do i set it up so that I can also use or something to that effect?

    5. admin says:

      Hi Madastro,
      I’ve not tried it yet myself, but you can edit windows HOST file. This tells your browser that is localhost.

      You can call your localhost anything you like, so you can have the line:

      Let me know if this works for you.

    6. Keith Davis says:

      Never even heard of Mercury even though it’s there everytime you open XAMPP… I must be blind!
      I’m trying to get the cforms plugin to send me an email from a local XAMPP WordPress setup.
      I’ve not tried your method but I’ve looked at a few methods which involve changing the php.ini file.

      Would you say that such methods are valid or should I bite the bullet and use your method.

    7. longthienquyen says:

      Hi,Thanks for your tutorial ,it work well

    8. rav says:

      Thanks for sharing!

      Works fine on Xampp and Outlook Express 6


    9. It is working well.
      Yet i have to set up multiple addresses to check.

    10. hasnain says:

      SMTP server response: 553 We do not relay non-local mail,

    11. vince says:

      Hi! Thanks for this tutorial IT WORKS!
      But I’ve a problem…there is a plugin in wordpress to send mail and it gives me an error just beacuse the mail address xxx@localhost looks like invalid…how can I create an email like ?
      Thank you!

    12. vince says:

      I’ve solved the problem , but I don’t know why it works :D
      I’ve used the address in the sender and in the receiver address fields…and it works well! But I’m asking myself why, because in the mercury configuration there is only xxx@localhost ( not .com or other domain) and even in the php.ini file the SMTP is localhost (not .com or other domain )

    13. vince says:

      I’ve found the “magic” …
      You can add as many domain as you want after the localhost…
      To do that, you have to:
      - from mercury homepage, go to configuration > mercury core module
      - click on the “local domain” tab
      Here are the domain already registered..and you can see the .com domain…
      You can add as many as you want all it will work
      example: xxx@localhost.mydomain
      and in thunderbird you have to modify the mail address to send and receive with the last domain…

      Hope this will be useful for others!

    14. leander says:

      This helped me solve my problem.


    15. sararith says:

      in the tutorial i found file: email.php run on the browser, so could you share this file for me? because i want to create php code to check all emails from localhost.

    Comments are closed.