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

Download

Installation
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 127.0.0.1 -localhost, for testing purposes only- or your actual IP adress assigned by your ISP (e.g 200.197.167.92).
    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

Configuration
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 200.197.167.92, but next time you connect to the internet your ISP assigns you a new one: 200.197.167.73

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 64.233.187.99 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 www.google.com 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 www.billyboy.com

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 gmail.com, hotmail.com, 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 = www.billyboy.com
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


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

Author: Site Editor

Share This Post On