Mail Server Mini-Howto

Chapter 3


Previous

 

Next

Setting up IMAP and POP

In this section, we will set up an IMAP4 and POP3 server. For more information about what IMAP is, go to the University of Washington IMAP Information Center.

  1. Download IMAP
  2. Extract the IMAP Source
  3. Edit the IMAP source files
  4. Compile It
  5. Move the Binaries
  6. Edit your inetd.conf

 

Download IMAP

First, you will need to download the IMAP source tarball. You can get this from ftp://ftp.cac.washington.edu/imap, look for the imap.tar.Z file, it should be a link to the latest version. As of this writing, the latest is imap-4.4.tar.Z.

Downloaded the file into /usr/src/tar (or wherever you like). In the examples to follow, I will assume that you downloaded the tarball into /usr/src/tar/imap.tar.Z.

 

Extract the IMAP Source

$ cd /usr/src
$ tar -zxf tar/imap.tar.Z

This will extract the IMAP source files into a directory called /usr/src/imap4.4 (or something like similar).

 

Edit the IMAP source files

We have to edit the IMAP source files to tell it where to look for our inbox, and where to store the IMAP folders. As I mentioned before, I want my inbox to be in ~/mail/inbox and my IMAP folders to be stored in ~/mail.

$ cd /usr/src/imap4.4/src/osdep/unix

Open env_unix.c in your favourite editor and search for the function char *sysinbox(). Change the line:

$ sprintf (tmp,"%s/%s",MAILSPOOL,myusername ());

to this

$ sprintf (tmp,"%s/inbox",myhomedir ()); 

Next, search for the function long env_init (char *user,char *home). Change the line:

$ myHomeDir = cpystr (home);

to this

$ sprintf (tmp,"%s/mail",home);
$ myHomeDir = cpystr (tmp); 

Save the file and exit the editor.

NOTE: A more elegant solution would be to have sysinbox and env_init read the MAIL environment variable to determine where the inbox is and possibly where to place imap folders. I'll leave that up to you :)

 

Compile It

Go into the IMAP source directory and compile it

$ cd /usr/src/imap4.4
$ make slx

You should read the documentation to see what what target you should be making. I use slx, but you might not.

 

Move the Binaries

Hopefully everything compiled for you, now you have to move the binaries that were compiled:

$ mv src/imapd/imapd /usr/sbin
$ mv src/ipopd/ipop3d /usr/sbin 

You can also move src/ipopd/ipop2d to /usr/sbin if you want a POP2 service.

 

Edit your inetd.conf

Open up /etc/inetd.conf and uncomment the the pop3 and imap entries. They should look this:

pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d
imap stream tcp nowait root /usr/sbin/tcpd imapd 

Save the file and restart inetd like so:

$ killall -HUP inetd

Voila, now you have IMAP and POP3 servers are now running. You might also want to check your /etc/services file to see that imap and pop3 services are there (should be on ports 143 and 110 respectively).

If everything went smoothly, then you should be able to connect to your box with any IMAP capable mail reader.

In the next section, we will look at configuring some Unix and Windows clients to work with the IMAP and POP services we just set up.

 

Previous

Next

Web Database Mini-Howto by Ying Zhang (ying @ zippydesign dot com)