How to – Setup Your Own E-mail Server

How to – Setup Your Own E-mail Server

What is a Mail Server
You know this. A mail server allows you to receive mails from other mail servers around the internet, provided you create user accounts. It also allows your users to send emails to other mail servers.

For this tutorial, we’ll use a solution that is freeware, and does its job perfect. I’ve been using it for about one year, for my local development in php.

1 Mercury/32 Mail Transport System 4.01a
This one directly from Pegasus Mail, by David Harris


This one is a little overwhelming, but once you’re done with it, the procedure for configure and get your server running becomes an easy, quick task.
Ill explain the steps carefully. Run the installer and press setup (this is a very simple self-extracting program, that leaves no trace in the registry, so to unistall, you simply remove the created folder in the installation)

  1. Press the button New Installation
  2. Since we wont be using support for Netware Networks, just press the button No Netware Support
  3. Now select the directory where you want to install Mercury (or simply extract the contents, as explained before). Recomended is the standard windows installation path C:\Program Files\Mercury. Press the button Ok, accept this directory
  4. Since the Mercury server can be used along with another mail client by the same company, Pegasus Mail (yes, the name of the company and the email client are the same), it asks you if you want to enable the support for such mail client. For reasons beyond the scope of this tutorial, we will not be using Pegasus Mail, so go ahead and press the button No Pegasus Mail integration
  5. Now it asks you for the directory where it should put the user mailboxes. Just leave it as-is (If you followed the recomended installation path, the it should show C:\Program Files\Mercury\MAIL). Press the button Ok, accept this directory
  6. Now it will ask you what protocol modules do you want to use. Basically, each one is a component in the form of a plugin, that will give you a given functionality. This is basically the core of the application. You can come back later and pick up the modules you want/require when you are more versed in these matters. For the moment just follow my advice to get this up quickly
    Select only the modules Mercury S and MercuryP (the first and second ones in the list).
    The first one will sit and listen from outside connections (aka when someone sends you an email to your own server), and everytime he receives one, this is put in the spool directory.
    The second simply will allow your POP3 client (outlook, thunderbird) to read email in an account in your server.
    Now press the button OK, continue installation
  7. Press the button Install MercuryE. This is the module that will handle delivery of mail to outside servers (aka when you send email from your own mail server to someone in yahoo, google, etc…)
  8. Now it should ask you for a domain name. This is your domain name in case you have one (or get one free at some of those free dns services around the net), or your own IP. This one can be either -localhost, for testing purposes only- or your actual IP adress assigned by your ISP (e.g
    The other field, postmaster, is simply what could be considered as the username in your machine that will act as the postmaster for the server, or what it is the same; the user who will get problem reports. Just use anything for the time being
    This is an example figure. We will use your ISP assigned IP, so that you can test this with an online connection, and in case you dont have a domain name. In the postmaster field, you can leave "Admin" which is the default, if you want to.
    Now press the button OK, continue installation, and we are ready to move on
  9. In this step, you will be asked about the relay controls. When you become familiar with relaying, you can chose the one that fits your needs. But for the moment, just press the button None
  10. Now its time to choose the Queue directory. Again, it should by default C:\Program Files\Mercury\QUEUE, then leave it as-is, and press the button OK, continue installation
  11. We are set. This is -at last – the final step. So go ahead and press that button Install Mercury/32 to stop the suffering
  12. Now, as a the worthless note ever, press the Exit button to close the installer

This is an easy step, compared with the installation process, believe me. So you can just relax, follow my instructions confortably, and you should have your server up and running in no time from this point.

So, run the server, which should have a submenu in the start menu, called Mercury for Win32; then pick up the item Mercury Loader
Now you should be presented with a window like this one, which is basically the control center of the application through the menus. You can see also 3 windows if you follow the instructions to the letter, each one represents respectively the Core Process that is the main module, and the POP3 and SMTP servers.

So, the next part if to create user accounts. Lets create one for this example. Go to Configuration-> Manage local users…, then press the button Add, and enter the details as required, like in the picture

Now press the button Ok and close the other window if you want to. And as you can see, now we have created the mail account [email protected]

There are two last things to do.
Go to Configuration->MercuryP POP3 Server, and simply fill in the field IP interface to use, in the case you’re using an IP and not a DNS.
So in the sample case we’ve been following around, this field needs to be filled up

Now do the same for Configuration->Mercury SMTP Server; i.e fill the field IP interface to use

Now all its left to do is to configure your mail client to be able to read/send mails using your newly created server and a user account.

Extra Configuration
What? There’s more?. Yep. In this section we will deal with two possible scenarios.

Scenario 1: Dynamic IP Address
Ok. What is a dynamic IP Address? Well, all dial-up users like myself, and some broadband ones, have what is known as a dynamic IP address asignation schema, which in plain english means you will have a different IP address every single time you connect to internet. This sucks. I know.
So, as you can see, we went through each of the installation/configuration steps pretending to have an example IP address, but everytime you connect to the internet, changes must be issued in order to update your mail server configuration.
Is there any solution for this? Yes. Check out the Help section at the end of this tutorial. For the time being, lets go over the wonders of Dynamic IP Addresses…
The first thing that needs to be done, is to update the corresponding values in the fields IP interface to use, revised in the last two images above.
So lets pretend your IP address is, but next time you connect to the internet your ISP assigns you a new one:

The next changes are located at Configuration->Mercury core module….
First one is on the tab General. Just change the field Internet name for this system accordingly

Now go to the tab Local Domains, select the second item, press the button Change entry, and enter the new value

Thats it. This needs to be done every single time you connect to the internet. Painfull I know

Scenario 2: Domain Name
So, you are a lucky one, and own a domain name. Domain names are basically ways for us human beings to remember internet directions easily. If I told you go to that wouldnt make much sense isnt it? So, go ahead and type that in your browser URL bar. What show up in the screen? Thats right, our beloved google. Which means that IP address is google address, and is simply google’s domain name.
Again, if you dont own a domain name and would like to have one, read the help section at the end.

Ok, so you have your own domain name, do you have to make all the "difficult" configuration stuff in the last subsection? Of course not. You wont have to change anything at all once you have configured the basics of your mail server.
Since it easier to explain how to install the mail server when you have a domain name, instead of showing you the changes required to use a domain name rather than an IP, go ahead and delete the folder C:\Program Files\Mercury, in case you already installed mercury and followed the instructions for using an IP 
No worries here, all aforementioned installation steps apply, with some minor differences. We will be using the example domain name

Step 8: Put your own domain name in the adecuate field
So the first two changes look like this

There is though one little thing to change when using a domain name. In order for the outside delivery to work, we need to add a valid dns lookup server (i.e so that you wont get an unresolved error for,, etc…). So, we fill in the field Identify Myself As: in Configuration->MercuryE SMTP Client

2.1 Outlook (Mail Client)
Since Outlook is very popular, and is bundled in M$ products, such as Office, Ill explain the configuration. Its really simple, so hopefully there’s no much to explain.

Thats it. Basically, your account properties should look like that, in the case you’re using a domain name, otherwise just fill in the IP

We’re done here. Now you should be able to send/receive emails (thanks to the POP3 module) through your own server in outlook.

2.2 PHP Mail (For programmers)
Now, if you are programmer looking forward to learn php, it always comes in handy to have your very own mail server for testing. So Ill just show you a sample php script to send mail through your server. Im going to use the Apache HTTP Server with PHP. Both need to be installed and working for this script to work properly Twisted Evil
Just FYI, Im running Apache 1.3.20 and PHP 4.3.10.

PHP Configuration

Open the file php.ini, likely located at c:\windows\php.ini. Now search for the line [mail function], and change the parameters in there accordingly (or fill them)

[mail function]
; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected]

Notice you can also use an IP instead of a domain name, or just localhost in case you are running the script locally, in the same PC where the mail server is.

Thats it. Basically, your account properties should look like that, in the case you’re using a domain name, otherwise just fill in the IP.
As you can guess by now, PHP uses the SMTP Server module to communicate with the mail server, and try to send mails through it.

The PHP Script
Made by myself, so do whatever you want with it, i.e public domain licensed. Not that its awesome in any sense…

File: mail.php

Sample Usage Script (Single destination email and plain text body)

File: use_mail1.php

Sample Usage Script (Several Destination emails plus html body)

File: use_mail2.php

We’re done at last. Hope you learn something useful with this tutorial, since IMO, its always tricky for a beginner to get a mail server up and running easily.
Theres obviously more to learn (a lot!) but thats outta the scope of this short tutorial, so you’ll have to go ahead and figure it out for yourself or search in internet. Only this way you might become a succesful mail server admin someday.

53 Comments How to – Setup Your Own E-mail Server

  1. Clifford Tetreault

    Great work! This is the type of info that should be shared around the internet. Shame on the search engines for not positioning this post higher! Come on over and visit my site . Thanks =)

  2. Daraper

    Boring and too long…. Sorry that ArgoSoft mail server does not work on Vista, that was that easiest way to use and did work.

    1. nick

      Hi, I am at university and for my final project, i want to build a website where an email client like hotmail, gmail etc exists that is dead simple and easy for senior citizens to use. this aint so bad in vis studio, but i need to get a server on my laptop to facilitate this where I dont have to add users, but they can do it themselves any suggestions where to look?
      Cheers Nick

      [email protected]

  3. Toby T. Rebold

    Wow. this is very useful. Setting up your own mail client could be very useful however, you should make sure first that you have a dedicated server capable of handling it. but if you are making it for personal use, i guess your pc's enough..

  4. Fenton

    Hi, First of all, thanks for the info. It looks like it might be just what I've been looking for.
    I'll explain what I'm trying to do and hopefully you'll be able to give me some additional pointers to get it all working.

    I have a WAMP setup on my machine, and that works fine for developing sites which I then place on an Internet Host, but what has always been a problem is getting the PHP mail() function to work on my localhost machine. I want to be able to test some scripts which will send email messages to customers, but am continually thwarted by the mail() limitation in not allowing username and password parameters, and Internet hosts in (sensibly) not allowing smtp facility without username and passwords. So, when I saw your page, I thought might just be what I'm looking for, a way to send emails to myself on my own machine via PHP scripts, purely for testing purposes.

    Now, here's the problem. I just can't get it to work. I have Mercury installed as per your instructions and am using the loopback address as an IP address, but am stumped at how to actually connect to the server. My email client is Eudora, and when I come to try and set up a new mailbox personality, I haven't got a clue what to enter in the account settings fields for smtp server and POP3.

    Hoping you can help.


  5. Zia

    I am trying to send emails from local server to gmail and yahoo but Mercury Core Process showing me Outgoing Jobs in Pending. I don't have domain but I am giving hosting solution to users. Why Outgoing Jobs showing mails are in Pending?

  6. dtyryyyyyyy


  7. moosechic

    hi guys, i'm just now looking at options to setup a mail server… can someone tell me, does this program run on XP or do i have to setup like a win2003 server for this to run? i didn't see any "requirement specs" on instructions…

  8. Martin Hemmer

    Very useful information. Thanks for this. You got a great blog .I will be interested in more similar topics.I’m very interested in CMS and all its related subjects.

  9. Rocknolds

    I have my domain “” from and pointed this to my Modem/Router’s ADSL WAN public ip address given by my ISP. I also have configured this modem/router for virtual servers forwarding POP3, Web Server, SMTP, IMAP, FTP to my XP host sitting in my private network.

    Web server and FTP server works fine.

    But mail server seems not working. I tried to follow all the instructions above.

    1. Matthew

      Alright all you do is set your mail servers internet address to your external IP (go to and then in the client program (eg Outlook Express) type in the mail server's internal IP (the one you get when you run ipconfig on the server)

  10. James Horsfall

    Trying to open a E-mail account but not responding ,because I don’t know servers adress

  11. Chaz

    Hi i was wondering i have a domain ( what do i put as my ip interface becuz i tried my ip and i can access it in outlook??? any help

  12. Cheles Dan

    I have xampp1.6. All of my outgoing mail’s are in pending. And i don’t know what to do. i have set you settings. I have a IP in sted of a domain.

  13. Wilfred Rosdorff

    Does the sendmail_path in php.ini not have to be set to the correct folder for the mail() function of php to work?

  14. pranali

    I have WAMP5 install pckg for PHP run show.
    Packg has APACHY server & MYSQL.

    I have installed & configure mercury as suggested.
    I’m using IP address instead of domain name.
    Still I couldn’t send mail. [:(]

    Kindly suggest if u have any better solution to work with it.

  15. jae

    Hey I am new to servers, php and mysql type stuff. I just want to ask you a question for my future goal:

    I want to setup a email service for the public like gmail, but for college students. I’m aiming for a setup very similiar to the gmail’s setup. How would I go about doing this?

    I’m good with photoshop and html so the design work is taken care of, but I’m beginning to learn php programming.

    1. John

      jae Wrote:

      Hey I am new to servers, php and mysql type stuff. I just want to ask you a question for my future goal:
      I want to setup a email service for the public like gmail, but for college students. I’m aiming for a setup very similiar to the gmail’s setup. How would I go about doing this?
      I’m good with photoshop and html so the design work is taken care of, but I’m beginning to learn php programming.


  16. Paul

    If you are using a server locally and you get a message from the SMTP server about not allowing non-local mail, simply open up your MERCURY.INI file located in the mercury program folder and locate the section:

    then at the bottom of that add:


  17. Sun

    i cnt find the help section mentioned above abt solution deal with dynamic address. I am facing that problem, anyone can help???

  18. Stale

    Hi Frank – if you haven’t changed the CNAME or MX records, don’t. If you have, just set them back by clicking ‘reset to default settings’

    Then, in the ‘domain control center’, on the right hand side, you’ll see a link that says ‘manage email accounts’ click it

    It should show you have one ‘credit’ to use. Also on that page is some pretty straightforward information on how to set things up, including the ‘catch all’ function.

    After that’s done, all you have to do is configure your mail retrieval system (Outlook, or whatever) to take the mail from the server you’ve configured. has plenty of support as well as far as setting up email accounts with their ‘’ mail server, if you should need further assistance.

    Hope this helps.


  19. Frank

    Peter I have the same problem, can you tell me how and what you add/chaged in the CNAME to make this work. I also use godaddy.


  20. Stale

    Me again, and I’ve figured out my problem: My ISP blocks outgoing connections to SMTP (port 25) which means I simply can’t host a mailserver unless I use a mail redirect function (such as the one found on ) to a non-standard port that my ISP doesn’t block. This costs money. Money that I don’t want to spend. So, for everyone out there that’s having problems, try telneting a mail server, and if you can’t connect, you can’t run a mail server. Details of how to telnet can be found on google – it’s easy.

    If you registered your domain through, they give you one free email addy – you just have to set it as a catch-all, and you can list everything (ie. [email protected], [email protected], etc.) and have it come to you. That’s what I ended up doing.

    Hope I can save someone the hours of crap I went through.


  21. Stale

    Hey, nice work. I own and am hosting it from my computer w/apache. I’ve figured out mysql and php and all that, but I’ve yet to get an email server running. I followed the install instructions to a ‘t’

    Perhaps I have to route the mail function (from my dns provider ( to my ip?)

    I’ll try that, and wait for it all to propagate.

    If you know something that I don’t, shoot me over an email!



  22. Ruhani Rabin

    Hi RageX,

    This article is a very basic thing to setup a simple mail server for testing.. Not really meant to be that versatile too. The freeware windows mail server mercury not versatile as commercial products like Alt-N M-Daemon Pro 9.xx which is extremely powerful e-mail server which can start an e-mail server in no time at windows platform. You can give it a try run.

  23. RageX

    I did everything you said for DNS and such but thing is im using a free dns and my isp block port 80

    So my webserver run on :81.
    My server box for test in lan is ( yes behind a router )
    Now in my router i forwarded the following.

    Virtual Server DNS UDP 53/53 always
    Virtual Server SMTP TCP 25/25 always
    Virtual Server POP3 TCP 110/110 always

    Even by putting announce myself as or or won’t work.

    Cannot resolve
    The reason why i setup this is for Outgoing mail’s to work for example i install a Test CMS and require validation by mail i want the mail to reach the user inbox.

    Any suggestion? if for example Mercury Mail wasn’t the best suggestion for this and i could use another programs to bind with an existing email adresse of mine .

    Anyway if you can help me on this would be appreciated.

  24. neelabh

    nice article…….but…………

    dont u think u have forgotten itz…… security part….

    that’s how to stop spammers to use open relay…….

    as any one following u r article will lead to serious security probs…………

    better consider it …….ASAP……

Comments are closed.