[XenoCafe Logo] Click for Homepage
Home Tutorials Forum Blog Advertising Links Contact About



Dovecot 0.99.14 IMAP Server on RedHat Linux 9

Written by Tony Bhimani
March 28, 2006

Requirements
RedHat Linux
Dovecot IMAP

This tutorial is a part one of two series for getting webmail up and running on a server. Webmal is a great way of accessing your mail from anywhere since all you need is a browser and internet connection. It's the same thing as Hotmail and Yahoo mail except you get mail from your own domain and you aren't hammered with banner ads. My webmail package of choice is SquirrelMail which grabs mail from an IMAP server. This tutorial will show you how to install and configure Dovecot 0.99.14. Why did I choose Dovecot? It's fast, stable, and a breeze to configure.

RedHat 9 doesn't come with Dovecot by default so we'll have to download it from rpmfind.net. There are some RPM versions of Dovecot that won't work with RedHat 9 even though they say they will. The one version I found that installs without conflicts is dovecot-0.99.14-1.0.rh9.rf.i386.rpm.

Make sure you're logged in as root and are in your home directory. Start by downloading the Dovecot RPM using wget.

wget ftp://fr2.rpmfind.net/linux/dag/redhat/9/en/i386/dag/RPMS/dovecot-0.99.14-1.0.rh9.rf.i386.rpm

Then install Dovecot with rpm -ivh dovecot-0.99.14-1.0.rh9.rf.i386.rpm

The install will place a config file in /etc called dovecot.conf. We'll need to change two things for our installation. Open dovecot.conf with a text editor like vi or pico.

vi /etc/dovecot.conf

First we need to change the protocols Dovecot will handle. Dovecot can service IMAP, IMAPS (Secure IMAP), POP3, and POP3S (Secure POP3). We won't be doing anything with the secure protocols in this guide, but feel free to experiment on your own. For this configuration we'll definitely need IMAP enabled and we'll throw in POP3 for fun. There may actually be a time when we'll want to set up a mail account using Outlook or some other mail client.

Add a new line below the commented protocols and set which protocols you want Dovecot to handle.

protocols = imap pop3

Now scroll much further down to around line 313. You'll see a commented line referencing mailbox locking mechanism. The default is dotlock and fcntl, but on two systems I left dotlock enabled I could never retrieve any mail from the IMAP server. I'm not sure what the problem was so I removed it and left only fcntl. It magically worked after that.

Add a new line below the commented mbox_locks and set it to only use fcntl.

mbox_locks = fcntl

Save your changes and exit your text editor.

Dovecot is ready to be started but first we need to have it start up on any reboots. We'll use chkconfig and add Dovecot to run levels 2, 3, 5 and then start the Dovecot service.

chkconfig --level 235 dovecot on
/etc/init.d/dovecot start

Verify Dovecot is running with ps.

ps aux | grep -i dovecot

As you can see Dovecot is running and listening for IMAP and POP3 connections. Now we'll do a couple tests to validate we can log in. We'll start with IMAP and then POP3.

telnet localhost 143
a01 login username password
a02 logout

We telnet to port 143 (IMAP) and issue a couple IMAP commands to login and then logout. Try it with a valid username on your system.

Since IMAP worked there should be no reason why POP3 shouldn't either.

telnet localhost 110
user username
pass password
quit

POP3 works as well. The only thing left to do is try it with a piece of mail and an email client. Start by dumping a mail message in one of your system accounts. For this example I'll place a basic message in my tony account using the mail command.

mail username
Subject: Test Message
Body: Testing Dovecot
[enter]
[enter]
.
[enter]

Replace username with a valid user on your system then type in a subject, body of the message, press enter twice, put in a period, and press enter one last time.

Check /var/spool/mail/username for your message using more.

more /var/spool/mail/username

The message is now waiting for retrieval. For the final test we'll configure a mail client (I'll be using Outlook Express) for my IMAP account and check my mail that way. NOTE: If you have a firewall (iptables) up on your server then either open port 143 or turn it off if it is safe to do so. Your remote system will timeout while attempting to connect to your IMAP server if it can't get to port 143.

In whatever email client you choose, create a new account and make sure it is for IMAP, enter the IP or FQDN for incoming and outgoing mail, and enter your system account username and password. You should then be able to retrieve your email through your IMAP server. The screenshot below is for Outlook Express.

Once the account is created there is a greeting asking to download the mail folders for the new server added.

Outlook Express fetches my mail and there is my message I sent using the mail program.

Viewing its contents it is indeed what I sent to myself.

That's it! You're done. You now have an IMAP server. The next part of this series will be installing and configuring SquirrelMail for webmail access. Continue to the SquirrelMail tutorial.



How would you rate the usefulness of this content?

Poor 1
2
3
4
5
6
7
8
9
Outstanding

Optional: Tell us why you rated the content this way.
Characters remaining: 1024
Average rating: 7.02 out of 9.

1 2 3 4 5 6 7 8 9
260 people have rated this content.
This page has been viewed 5,630 times
Copyright © 2004-2008 XenoCafe. All Rights Reserved. XenoCafe is Powered by Linux. Free your mind and your wallet. Switch to Linux.