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)
- Press the button New Installation
- Since we wont be using support for Netware Networks, just press the button No Netware Support
- 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
- 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
- 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
- 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
- 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…)
- 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 188.8.131.52).
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 &amp;amp;amp;amp;amp;quot;Admin&amp;amp;amp;amp;amp;quot; which is the default, if you want to.
Now press the button OK, continue installation, and we are ready to move on
- 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
- 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
- We are set. This is -at last – the final step. So go ahead and press that button Install Mercury/32 to stop the suffering
- 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-&amp;amp;amp;amp;amp;gt; 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-&amp;amp;amp;amp;amp;gt;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-&amp;amp;amp;amp;amp;gt;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.
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 184.108.40.206, but next time you connect to the internet your ISP assigns you a new one: 220.127.116.11
The next changes are located at Configuration-&amp;amp;amp;amp;amp;gt;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 18.104.22.168 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 &amp;amp;amp;amp;amp;quot;difficult&amp;amp;amp;amp;amp;quot; 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-&amp;amp;amp;amp;amp;gt;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
Just FYI, Im running Apache 1.3.20 and PHP 4.3.10.
Open the file php.ini, likely located at c:\windows\php.ini. Now search for the line , and change the parameters in there accordingly (or fill them)
; 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…
Sample Usage Script (Single destination email and plain text body)
Sample Usage Script (Several Destination emails plus html body)
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.