Pre Installation

# Setting up a mail server

So you want to setup a mail server, here we will quickly run through what is required and things you will need to setup before actually getting the server up and running. Some of these can be done after the server is installed but it's best to keep them in mind before you start.

### Buy your domain name

Generally you will need your own domain e.g. mydomain.com, then you can setup email accounts for that domain, so you will email addresses like user1@mydomain.com etc. People will be able to send to user1@mydomain.com and that user will be able to login with an email client such as outlook express and receive that message, they can also use the built in web based email client WebMail to check their mail.

There are a lot of Internet registrars that sell domains so you should shop around for the best deal you can find and usually buying the domain for a few years at a time gives you a discount.

You can find a list of Internet Registrars from these sites.
http://www.internic.net/alpha.html
http://www.icann.org/registrars/accredited-list.html

### Setup DNS records

Once you have your domain, then you need to setup the DNS records for it. There are several types of DNS records but as far as mail is concerned we are interested in the A records and the MX records.

MX (Mail Exchange) records are only used by mail servers and they tell other mail servers where to send mail for your domain, so it is important to set these up.

If you go to the command prompt in Windows or the shell in *nix you can type
nslookup
set type=MX
netwinsite.com

You will then see this:
Non-authoritative answer:
netwinsite.com MX preference = 25, mail exchanger = smtp.netwin.co.nz
netwinsite.com MX preference = 10, mail exchanger = mail.netwinsite.com
netwinsite.com MX preference = 20, mail exchanger = netwin.co.nz

We can see netwinsite.com has 3 MX records. The way MX records work is the lowest number has the highest priority, so if I send an email to netwinsite.com, the server will first try to send to the the record with 10 (mail.netwinsite.com) if that machine is down, then it tries the next MX record and so on and so on until it finds what that is working and then it delivers the message.

It's a good idea to try and setup at least 2 MX records this of course requires two servers, this means if your main server is down, the mail will get sent to the secondary machine which then forwards it to the primary once it comes back up again. This isn't essential though because even if you only have 1 mail server and 1 mx record, if a server sends to you and your server is down, the sending server usually will keep trying to deliver the message to your server for at least 24 hours.

In the above MX records, each MX record then points at an A record, mail.netwinsite.com is an A record which would resolve to the IP of the machine running SurgeMail.

To setup MX and A records you will need a DNS, this can be a little complicated to setup for some people.
Your ISP might be able to help you here, so you should contact them and ask them about this. There are also commercial DNS servers out there, and if you are running a small non commercial server there are some free ones.(http://www.xname.org) - just search around on google.
You can also run your own DNS server, on *nix most people run BIND.
On windows you can try "Simple DNS Plus" which seems very easy and also on windows 2000/2003 server there is a built in DNS server you can use. You definitely need two DNS servers as if you only have one and it goes down for some reason, no one will be able to send mail to you.

* Please note we will not give direct support on configuring DNS servers but can offer advise on setting up DNS records in general.

So, the main things are:

1. Setup at least 1 MX record, so that mail servers know where to send mail for your domain
2. The MX record needs to point at an A record which has the IP of your server.
   The A record is also what your customers will use in their email clients for the smtp server and pop server.

### Example

We have bought our new domain "mydomain.com"
The machine we are going to put SurgeMail on is 1.2.3.4
We setup an A record mail.mydomain.com that points to 1.2.3.4
We then setup an MX record pointing at mail.mydomain.com
Your customers will put mail.mydomain.com in their mail client in the SMTP/POP server sections.

You now need to check that your ISP is not blocking port 25.
At the command prompt type
telnet mail.netwinsite.com 25
You should get a response like this
220 netwinsite.com SurgeSMTP (Version 3.0c2-2) http://surgemail.com

If it says unable to connect, then it's possible your ISP is blocking port 25 and you should contact them, or try telnetting again to our server a few minutes later incase we were doing maintenance :). If your ISP is blocking port 25 then all is not lost, you can tell SurgeMail to send it's mail via your ISP's mail server and you can read how to do that here.

You need to make sure that you open all the ports for SurgeMail. You can read which ports are required here. This will require you allowing them in your firewall, and if you are using a router you will need to add pinholes for these ports through to the machine running surgemail.

OK now you have everything ready to install SurgeMail.

After which you will need to do some post installation steps.