Setting up an email server in three days

Published on 01/21/08

The last three days of last week were spent building my own email server. Can I just tell you that it was fun, rewarding, and the biggest pain I have ever had to deal regarding web server administration.

My email hosting provider was unreliable

My email has been hosted on a site 5 hosting account for about a year or so. When I first switched to site5 from dreamhost, I was thrilled with the level of service and the level of performance of their servers.

Well that all has gone down the tubes lately. What originally drew me to them was that they limited the number of customers that were on each server. Their plans no longer say this, and the large number of sites running on the same server has caused increasing outages over the last couple of months.

Besides the outages, there firewall started blocking access from my home network for some reason. They fixed it pretty quickly, but it made me wonder how reliable service was to the server from other locations (like anyone wanting to send email to me).

Then I noticed that that server’s ip address was black-listed by several email servers (I guess someone was sending spam from it). So it got to the point that I could not rely on email coming in and email going out. So I created a gmail account so I could get reliable email service, but I wanted to get back to being able to use my own domain’s email.

Setting up the server

So, I went ahead and created a new VPS with my current host, slicehost, and started looking for tutorials on setting up an email server. There are many different ways to do this, and none of them are particularly easy. Here is the setup that I decided on:

  • Postfix for MDA – No particular reason for choosing postfix other than I had the impression that sendmail was more difficult to configure.
  • Dovecot for imap/pop3 – I knew for sure that dovecot was easily configured with postfix
  • Mysql – database for storing virtual hosts and emails addresses.

Now for setting up the server, I basically followed the instructions in this tutorial. I liked this tutorial because it explained concepts and then gave a list of steps (rather than just a list of steps). It is much easier to trouble-shoot problems when you understand what you are doing.

Now, the tutorial is specifically for debian linux, and my VPS was setup using fedora8 (I use fedora by default because they keep up packages for nginx, my web-server of choice for rails projects). This was not a real problem other than the postfix that is installed with yum is not built with mysql support. So I needed to get a fedora8 rpm and build it with mysql support enabled. I got instructions for doing that on this tutorial here. I only used this tutorial for the url of the fc8 rpm for postfix and then instructions for building with mysql support. I had to install some of the packages that were listed at the beginning of the article, though I am not sure which ones are required for sure, so I just did all of them. Also, I did not install the patch for quotas because my setup uses dovecot as the LDA.

So, after three days of messing around and pulling out hair (the pulling out hair was mostly because of things that I had not configured correctly at first), I have an email server up and running. I spent part of the day-after building a small rails app for administering email accounts, so now I have an email server with and easy web interface for setting up accounts.