Okay, I have setup an email server for my company and with this little experience, I will write a simple tutorial on what you need to setup an completely working basic email server. I would highly recommend setting up a completely secure virus and spam protected mail server. Note that this may not be complete or I may have missed out on something, so please bare with me.
Here are the steps:
1. Get a domain name as well as DNS hosting. You can get your domain name (like something.com or domainname.org) from the domain registrars like Godaddy or Directdomains. I would recommend Godaddy. Do not confuse Domain management and DNS hosting. Although related, they are actually separate. Domain management manages your Domain Name, like your registrant profile and contacts and allows you to set your Name Servers. DNS hosting ( which you set as Name Servers in your Domain management system) publishes your DNS records like the MX (Mail Exchanger)Â Records, A Record and IP addresses of your mail server or your web server. MX Record is the most important thing if you are setting up an email server, it tells anyone sending mails to your domain where (which IP Address) to route your mails to, so make sure you set it correctly. MX records must be a fully qualified domain name (FQDN) and cannot be a CNAME record.
You can of course host your own DNS Server(which means that you need to point your Name Servers to your own DNS Server) but there are several free and reliable DNS hosting service available like Xname and Zoneedit. These provide a web-based interface for you to configure your DNS records. You can even add additional secondary Name Servers (like Twisted4Life) by using redundant Name Servers. Note if you change or add Name Servers (at the Domain Registrars), there will be a propagation delay of up to 72 hrs (but usually it will be fully propagated in 24 hrs). Editing or adding DNS records will be almost instantaneous. However, it also depends on your DNS service.
2. Static IP Address. This is very important nowadays. If you are using dynamic IP address (in the past, all you have to do is use a DDNS service to automatically change your DNS records whenever your IP Address change), you will face a lot of problems like change in IP address and not having the correct PTR Record. With the increase in spam and with new methods to combat spam, a lot of email servers now reject mails sent from mail servers whose IP address does not have a PTR Record. Most dynamic IP addresses do have any PTR record and most ISP don’t allow PTR records on dynamic IP address range since they shouldn’t be used as a SMTP server. I will cover more on PTR records later. There are email servers which check whether the SMTP connection is from a IP address which is known to be a dynamic pool and may reject it.
Another thing, there are some ISP which provides static IP addresses but however, it has one “WAN” IP and several “LAN” IP addresses. Although all these IP addresses are all public (they are not private IP Addresses), but anyone from the outside will only “see” any connection from the WAN IP(Gateway IP). So if your ISP provides, you need to change the PTR record of your WAN IP instead of the LAN IP.
3. Bandwidth. Yes, you need to have enough bandwidth to send and receive mails to your mail server as well as for clients to send and receive mails too. Of course, the bigger the bandwidth, the better. Some ISPs provide slower upload speeds than download speeds, which may result in bottlenecks in your email system.
4. Email Server (hardware). I leave this to your own discretion. If you handle a lot of emails, then you should prepare to get a higher end server. A lot of it also depends on your harddisk (and RAM) since an email server does a lot of swapping with small pieces data being processed constantly. I would recommend a Hardware RAID system setup for your email server if you can afford it.
You will also need the figure out how much harddisk space you need. If you have a lot of users, you might need more storage space for your emails.
And your server should be able to handle the load required. Since it should be on 24 hours, you need the server to be placed where there is good ventilation or is air-conditioned. And the power supply is reliable. You won’t want the power to trip often and the server will be down for the count.
4. Email Server (Software). Another one which will depend on your requirement and budget. I will recommend a linux email server but it requires a certain amount of skill and experience with Linux systems. There are a lot of resources available on the Internet on setting up a linux email server and there are even distros out there which comes pre-complied with everything you need to setup your mail server right out of the box. But there are a lot of good Windows Email Server software as well like Mdaemon and Kerio Mail Server. However, their prices are a bit on the high side when you compare them to some Linux solutions.
Also commercial versions of email servers may come with anti-virus and anti-spam solutions built-in, saving you the trouble of installing and configuring any additional services. Not to be overdone, there are open source solutions which does the job of providing anti-virus and anti-spam protection too. However, most require some work and effort to setup.
5. PTR Records. This is a very important step to get your mail server working properly. The PTR records is not done through the DNS Records but it has to be done by your ISP, the one that provides you with the static IP address. You should try to use the same domain name for your PTR Record as with your email server. Email servers uses the PTR record to make sure your mail server is who it claims to be and is not spoofed/fake to fight spammers using their own mail relays to send spam.
6. Anti-virus. Another important feature for your mail server. Although it is not “critical”, it is nonetheless very very important. The main spread of virus is through emails and if you don’t have a good anti-virus system setup on your mail server, your recipients may get infected (from virus infected mails) and they too will continue spreading viruses to others.
There are a lot of ways to setup an anti-virus filter for your mail server. If your mail server allows it, you can install or configure an anti-virus software to scan all incoming mails (and even outgoing mails) for viruses. Or you can setup an anti-virus relay server which scans for mails and removes/rejects virus infected emails and then relays clean ones to your actual mail server.
You can take a look at ClamAV as a anti-virus tool, especially designed for scanning for viruses at email gateways.
7. Anti-spam. For security purposes you should setup your mail server to do reverse DNS lookup on incoming SMTP. This way, you will have at least a certain amount of protection against spammers. There is also SPF check (this uses the DNS records) which helps to authenticate the sender (his/her email address) and whether the incoming SMTP Server is supposed to send mails for that particular sender or not. You can also try DKIM (Domain Keys) as an authentication system to combat the spam problem.
There are a lot of other anti-spam methods, like blacklist lookup or using Spam Assassin or Bayesian Filtering or some other filtering method to filter out spam. Or you can simply use a combination of these methods. Note that just like for anti-virus system, these methods require server resources to implement, so make sure your server can handle the additional load first. We don’t want to crash your email server now, do we?
And just like your anti-virus system, there are many ways to setup your filtering system, by installing it directly on your mail server or through an anti-spam relay. Nowadays, most people will have both anti-virus and anti-spam on their system.
8. Secure your mail server. Authenticate your users and do not allow your mail server to be used as an open relay. There are ways to authenticate your users like SMTP authentication, POP before SMTP and so on to prevent spammers from using your mail server.
Here are some web tools to help you check whether your mail server is having problems or to troubleshoot any mail problem you might have. MX Lookup Tool and DNS Stuff. These web tools can provide valuable information on your server settings.
Hope this little tutorial/guide can help you start setting up your very own email server. If you have any questions or comment, please by all means, comment here.
