Quick and easy pop or imap server with Dovecot

Jack Wallen
Feb 25, 2010
Updated • Nov 30, 2012

Picking up where we left off a while ago, let's add yet another feature to our Ubuntu server. We've already looked at using Postfix with multiple topics (see Postfix on Ghacks). But we never discussed a means to deliver the mail from the server to the client. That will now change. Linux has multiple ways to deliver email to clients. One of the easiest (as well as most flexible) means is via Dovecot.

Dovecot is an open source IMAP/POP server that runs on either Linux or UNIX systems. Dovecot is suitable for both small and large installations (I just recently installed Dovecot on a 300+ user system) and will work in the background like a workhorse.

In this article I will show you how to install Dovecot and get it up and running with either IMAP or POP quickly and with as little pain as possible.


Since we are installing on a Ubuntu machine, installing Dovecot is as simple as running the command sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d. You can actually install either dovecot-imapd or dovecot-pop3d depending upon which protocol you need to support.

Once installed the executable command is /etc/init.d/dovecot start.


There is only one configuration file you need to deal with. That file will be located in either /etc/dovecot.conf or /etc/dovecot/dovecot.conf. Believe it or not, the default configuration file is fairly well set up for you. You will only have to make a few modifications. So don't let the 1,000+ line configuration file look you in the eye and defeat you. You can best this beast with little time.

The first configuration you will need to make is to configure the protocol. Look for the line:

protocols = pop3 pop3s imap imaps

You can just leave this as is, or, if you know you are only using certain protocols, edit to suit your set up. Just remove the protocols you do not need.

The next line you need to look for is:

mail_location =

There are two popular choices here:
mail_location = maildir:~/Maildir # (for maildir)
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)

In other words, if your users' mailboxes will reside in the home directory, use the former. If the users' mailboxes will reside in /var/spool/mail, use the latter.

Restart and test

Now restart Dovecot with the command /etc/init.d/dovecot restart and let's give this system a test. We'll test this with the help of telnet. Issue the command telent ADDRESS PROTO Where ADDRESS is the address of the server and PROTO is the protocol you want to use (either pop3 or imap). Here's what the test will look like:
telnet localhost pop3
+OK dovecot ready.
user USER
+OK Logged in.
+OK 1 messages:
1 622

Where USER is a legitimate user on the system and PASSWORD is the password for that user.

If you see the +OK at the end, Dovecot is ready to go. If you have any problems, the best place to look is in /var/log/maillog. And the best way to run that check is by using two terminal windows. In terminal A issue the command tail -f /var/log/maillog and in terminal B run the Dovecot test above. Terminal A should report any issues which will be your starting point for troubleshooting.

Final thoughts

Dovecot really is that easy to install. Of course Dovecot is much more flexible than that. In later articles we will discuss other configuration options for this outstanding server.


Tutorials & Tips

Previous Post: «
Next Post: «


  1. awesome said on February 25, 2010 at 5:22 pm

    dovecot is such much easier to get working that courier, IMO. i’ve had a lot of problems using courier in my days, but dovecut always works as it should

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.