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 marktest1@localhost.com
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.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • NewsVine
  • Reddit
  • StumbleUpon
  • Tumblr
  • Twitter
  • Yahoo! Buzz
This entry was posted in IT, Websites, how to and tagged , , . Bookmark the permalink.

9 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.

    thanks!

  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 mail@localhost.com 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 127.0.0.1 is localhost.

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

    Let me know if this works for you.

  6. Keith Davis says:

    Hi
    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">