Setting Up a Mail Server Using iRedMail

A short overview of what we did, with some quick tips on adding email aliases.


After finding out about Windows Live Admin Center shutting down, I thought I’d investigate the best way to set up our own mail server for Obstance. There was the option of upgrading to Office 365, but the cost for a small business subscription really didn’t appeal to me. After doing some research, I decided that iRedMail would be the ticket. It’s an open source mail server solution that comes packaged with a variety of well-known software: Postfix, Dovecot, Cluebringer, Roundcube, and a several others.

Since these repositories are all maintained across several different distributions, you can rest easy knowing that you’ll be able to keep your system up to date. iRedMail is fantastic for those looking to deploy a mail server quickly, with the ability to easily reproduce your set up. We did so in as little as an hour. It’s technically a lot faster than that, but a lot of time was spent actively testing the emailing and rummaging through the different configurations that make the system run.

This won’t be a how-to, but I’ll describe some of the process in how I got our email server set up. Firstly, check out the official website documentation to see if it’s something for you. We spun up a new $10/m droplet on DigitalOcean, which comes with 1GB memory, a 30GB solid state drive, and 2 terabytes of bandwidth transfer. Much more than we actually need for our small business. I bolded the RAM because iRedMail requires at least that much for a functional production server.

There are plenty of people that have the mail server set up on much less than 1GB of memory, but I wouldn’t recommend doing so unless you know what you’re doing. You’ll most definitely need to disable Clamav (anti-virus), and possibly opt out of using a front-end HTTP server, if you want to use less than a gigabyte of RAM. Of course there are different ways of going about it, but overall it’s best to spin up a VPS with the recommended amount of resources. iRedMail comes with configurations that need that amount of resources, so don’t use anything less if you’re not planning on touching any configs.

With Ubuntu 14.04 LTS on our VPS, I just simply followed the installation guide. Yeah, that goes fast.

After following that guide, which took all of three minutes out of my day, there were some things I wanted to do. I realized that email aliases in iRedMail aren’t supported in the free version if you’re using the Web UI, so I had to execute some MySQL commands to do that:

mysql -u root -p
USE vmail;
INSERT INTO alias (address, goto, domain) values ('user@example.com', 'postmaster@example.com', 'example.com');

With the above, we’re adding an email alias and having it directed to postmaster@example.com. I did this for all of the different common email aliases so we didn’t have to create several new accounts (hostmaster, webmaster, admin, and so on).

I wanted to be able to use one email account in Roundcube, without having to log in and out of different ones. To do that, I needed to create identities in Roundcube, but that’s disabled by default. So to enable it, I had to go into /usr/share/apache2/roundcubemail/config/config.inc.php and search for “identities.” This line needed to be changed from a three to a zero, as shown below.

$config[‘identities_level’] = 0;

This allows us to go back into the mail server’s front end, mail.example.com, log into our primary account, and then add email identities so that we can use a drop-down when replying to emails. For instance, a client emails us at admin@example.com, and since that’s technically not an email we’ve set up — it’s a alias — we receive the email in postmaster@example.com. To keep things consistent, we’d like to reply with the admin email instead of confusing the client by replying with postmaster. Identities allow us to do just that, keeping things consistent for clients while making it easier to maintain emails on our end.

There’s one thing about that, though: again by default, there’s a setting in Postfix that will flag these identities as a mismatch and won’t send the email. A mismatch would be trying to send an email fromadmin, but being logged into postmaster. To allow the emails through, we open up the config file at /etc/postfix/main.cf and search for sender_login_mismatch. Remove that, and we’ll be able to send out alias emails through our primary account!

Running our own mail server for the past few days has been a great experience, filled with both fun and frustration. The frustration stems from modifying things I had no idea about, so don’t let that worry you. A mail server is an entirely new thing for me, but it’s been something I’ve been thinking about for a while. If you have been thinking of doing something like this, I highly recommend giving iRedMail a shot. It sets most of it up for you while still allowing you access to all of the code for you to destroy, so that you can modify anything you might want changed. There are a plethora of great articles online as well, so don’t worry if you can’t figure something out by yourself.

Do you run your own mail server or are you thinking about it? Consider looking into Xeams or Citadel, I’ve been hearing some good things about those two.