Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know of a tutorial that takes me from having registered a domain name (with eNom through Google) to a running IMAP mail server (preferably based on Ubuntu) connected to the internet via a ADSL connection? I am looking for something quite specific if possible as I have very little experience with mail related issues.


So I have tried to follow the instructions in the answers below (and a few places on the net). I have done the following:

I have used my enom control panel to delete the existing records created by Google Apps for domains and created (only) the following records (IPs are fake, I have a static IP from my ADSL provider which I have used):

@ A-record
www A-record

@ MX-record
mail MX-record

I have forwarded port 25, 110, 143, 993 and 995 from my router (a Netgear WNR2000) to my mail server (Mail Station on a Synology CS-407).

I cannot receive any mails but I can send them without any problems. What am I missing? As a test I have also tried forwarding port 80 while running a simple webserver on my mail machine. If I try to access my domain from a web browser I am prompted to log into my router. There is no firewall running on my router.


Got it working by inserting a second MX record referring to my ISP's backup SMTP server with a pref of 20 (my own has pref 10).

share|improve this question
You mention you have a ADSL connection, but is this simply a consumer link or a business link? SMTP is blocked by many ISPs these days on consumer connections. – Zoredache Aug 25 '09 at 19:43
As far as the web browser getting the router instead of you web server, you need to change the port your router listens on for its web interface. – John Gardeniers Aug 25 '09 at 19:47
I cannot figure out how to move the web interface to a different port. My connection is a professional connection so SMTP should work. – mac Aug 25 '09 at 20:09
Forgot to reiterate that I can send mails just not receive them. I guess this would mean that there is no block on SMTP? – mac Aug 25 '09 at 20:16
up vote 3 down vote accepted
  • First of all, you'd have to link your dynamic IP address to your own domain name. This can be done through services like No-IP or DynDNS. Ideally, you should have a static IP address, but if you can't have one, you should route your outgoig mail traffic through an intermediate SMTP server instead of delivering it directly from your own server (this is what EK suggested).
  • As a second step, you have to set up MX records for your domain. Probably your registrar can provide specific instructions on how to do that, but if you use No-IP or DynDNS for domain name resolution, you should do that from their control panel.
  • Then you can set up your mail server. Depending on your requirements, the process can be quite complex. Since you've asked specifically for a tutorial on how to this on Ubuntu, see for example Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail by Falko Timme. That tutorial gives you step by step instruction for setting up you mail services (SMTP, IMAP, webmail) and also covers other topics such as setting up TLS, quotas and antivirus/antispam.
  • You can find lots of tutorials on setting up mail services on an Ubuntu based server, each of them covering a different product mix. So it would be a good idea to decide what products you'd like to use, and then looking for more instructions. For example: would you like to use Postfix or Exim? Do you prefer storing virtual accounts on a MySQL database or do you need an LDAP backend?

I don't know what are the specific requirements for your mail server, but anyway I'd suggest looking at Google Apps instead of deploying your own server.

share|improve this answer
I have Google Apps running but do not like the idea of Google controlling my mail and would like to run my own mail server as an alternative to see if it is worth the effort. – mac Aug 24 '09 at 11:30
I understand :) And I think that there are lots of valid reasons for not using Google Apps. I just mentioned it in case you weren't aware that you had that option, since it's something that you can have up and running in a couple of minutes. But doing it yourself can provide an excellent learning experience, and if you need further assistance, here at Server Fault you have a large community that will be happy to help. – mfriedman Aug 24 '09 at 11:46

The main steps are:

  • ask your ADSL provider a dedicated IP address
  • ask your registrar to associate your IP address to your domain name
  • configure your ADSL router so that it redirects incoming internet traffic to your computer
  • run a mail server on your computer
share|improve this answer

You will probably need an intermediate SMTP host such as your ISP or someone like messagelabs if you intend to send out mail as most people running mail servers blacklist IP ranges being used for broadband by default. (because of spamming trojans)

share|improve this answer

You say that you have very little experience with mail related issues. Unless you are very, very serious about this and committed to learning a lot, I would seriously recommend that you use mail services provided by somebody who does this for a living. There are plenty companies that will offer email services for your domain for affordable money.

The amount of time that goes into properly configuring a mail server and constantly looking after it should not be underestimated.

share|improve this answer
I have been so advised and remain committed and ready to learn :-) – mac Aug 24 '09 at 11:58
OK, you have been warned. The default mail server under Ubuntu is exim, which is an excellent choice in terms of flexibility and security. The exim community has excellent online documentation at This will handle the SMTP part, you then need a server/daemon that handles the IMAP part. For this I would recommend courier-imap, which is also a standard package under Ubuntu, and they have documentation at Good Luck. – wolfgangsz Aug 24 '09 at 12:23

I would like to add that in most cases, your ISP would filter port 25 connections. So, even if you do set up your server and MX entries correctly, you may still not be able to send/receive any mail. You may need to go through your ISP mail server. This is part of their spam prevention policies.

share|improve this answer

1) You should change the setting on your router that lets someone connect to the management functions from outside. Do this right away.

2) From a connection other than your ADSL line,

telnet 25

where is your IP address. If you can't connect to your SMTP server from outside, that's why you can't receive e-mail. I'm not familiar with the e-mail server you're using, but this network connectivity test would something to try no matter what server you're using.

3) When you start using your own e-mail server, if you're not relaying via your ISP's SMTP server, you're going to need your ISP to set up reverse DNS on your IP address. If you don't have this, you're going to have a lot of e-mail not delivered. Also a SPF record is a good idea.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.