Mac OS X Unleashed

Mac OS X Unleashed

By John Ray and William C. Ray

University of Washington imapd

Sendmail makes up only part of the mail-server picture. Although Sendmail handles sending and receiving e-mail on the server side, it does not have any provisions for the client software, such as Eudora or Outlook Express. To provide e-mail for remote clients, Mac OS X will need an IMAP server, a POP3 server, or both. Thankfully, the University of Washington has created an easy-to-install software package that will kill two birds with one stone.

The UW imapd server is capable of handling both IMAP and POP3 traffic and it is already Mac OS X–aware, so it takes very little work to install. Even better, there is absolutely no configuration file for the software, so after it's installed, it's ready to use.

Installing UW imapd

Installing imapd is straightforward, but will require a few additional modifications to be able to perform smoothly on your OS X computer. To start, fetch the current sources from ftp://ftp.cac.washington.edu/imap/. Unarchive the source and cd into the distribution directory:

[primal:~] jray% curl -o ftp://ftp.cac.washington.edu/imap/imap.tar.Z
[primal:~] jray% tar zxf imap.tar.Z
[primal:~] jray% cd imap-2001.BETA.SNAP-0106252013/

Before compiling, there is a very important change that should be made to the file src/osdep/unix/env_unix.c. By default, the IMAP server will attempt to create all mailboxes directly in the user's home directory. In fact, it assumes that any directory in the home directory is an IMAP folder. This results in potentially hundreds (or thousands) of folders being downloaded and displayed. To get around this, the env_unix.c file must be adjusted so that a directory other than the main home directory is used. This can be any directory, as long as it exists in every user's account. A good choice is ~/Library/Mail/Mailboxes because it contains the mailboxes created by the Mail application. This enables remote access to mail downloaded onto the Mac OS X computer. Just remember to create the directory name you choose in each account that will access the IMAP server.

Edit the src/osdep/unix/env_unix.c file to add the mailbox directory name you've chosen. Look for a line reading

static char *mailsubdir = NIL;  /* mail subdirectory name */

Change the text to include the directory you've chosen. For example

static char *mailsubdir = "Library/Mail/Mailboxes";     /* mail subdirectory
name */

The source code is now ready to compile using make osx:

[primal:~/imap-2001.BETA.SNAP-0106252013] jray% make osx
Applying an process to sources...
tools/an "ln -s" src/c-client c-client
tools/an "ln -s" src/ansilib c-client
tools/an "ln -s" src/charset c-client
tools/an "ln -s" src/osdep/unix c-client
tools/an "ln -s" src/mtest mtest
...

The compile process takes only a minute or two because the server application is really quite small. Unfortunately, installation of the compiled software is not automated, so you will need to copy the binary files to an appropriate location.

The Mac OS X /etc/inetd.conf file already has entries for the IMAP and POP servers, so we'll just use the standard settings (/usr/local/libexec/). You'll have to create the libexec directory within /usr/local, then copy the files imapd and ipop3d to the new directory:

[primal:~/imap-2001] jray% mkdir /usr/local/libexec
[primal:~/imap-2001] jray% sudo cp imapd/imapd /usr/local/libexec/
[primal:~/imap-2001] jray% sudo cp ipopd/ipop3d /usr/local/libexec/

Next, edit the /etc/inetd.conf file to uncomment the imap and pop server entries. You need uncomment (remove the # character) only the line for the server you want to run. If you want both, uncomment both lines. In addition, you'll need to change the name of the POP3 server to match the installed binary (ipopd). The original two lines read:

##pop3  stream  tcp  nowait  root  /usr/libexec/tcpd  /usr/local/libexec/popper
##imap4 stream  tcp  nowait  root  /usr/libexec/tcpd  /usr/local/libexec/imapd

The modified versions should look like this

pop3  stream  tcp  nowait  root  /usr/libexec/tcpd    /usr/local/libexec/ipop3d
imap4 stream  tcp  nowait  root  /usr/libexec/tcpd    /usr/local/libexec/imapd

Adding Services to NetInfo

On most Unix systems, you would finish the install by adding entries for the protocols pop3 and imap4 to the /etc/services file. Under Mac OS X, however, this file is replaced by the NetInfo database. Chapter 23 provides an introduction to NetInfo.

There are two different methods for adding service definitions to the NetInfo database—through the command line and via the graphical NetInfo manager. This chapter will examine the command-line version, and Chapter 30, "Accessing and Serving a Windows Network," will demonstrate the GUI procedure. Either way, the result is the same.

Two protocol definitions must be added to the NetInfo database:

and

To add these entries to your local NetInfo database, use the nicl utility as follows. First, the IMAP4 protocol:

[primal:~] jray% sudo nicl / -create /services/imap4 name imap
[primal:~] jray% sudo nicl / -append /services/imap4 port 143
[primal:~] jray% sudo nicl / -append /services/imap4 protocol tcp

Next, POP3:

[primal:~] jray% sudo nicl / -create /services/pop3 name pop3
[primal:~] jray% sudo nicl / -append /services/pop3 port 110
[primal:~] jray% sudo nicl / -append /services/pop3 protocol tcp

Finally, reboot the Mac OS X computer, or force the inetd process to reload its configuration using kill -1 and the inetd process ID.

Test to make sure that the services you want to run are running by telneting into port 110 (POP3) and port 143 (IMAP):

[primal:/Users/jray] root# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.ag.ohio-state.edu.
+OK POP3 primal.ag.ohio-state.edu v2001.76 server ready
Escape character is '^]'.
Connection closed by foreign host.

and

[primal:/Users/jray] root# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.ag.ohio-state.edu.
Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN] localhost.ag.ohio-state.edu

      ccc.gif
    IMAP4rev1 2001.309 at Wed, 27 Jun 2001 19:01:15 -0400 (EDT)

Both services are running, as we intended. As a rule, remember that less is more when it comes to servers. If you aren't going to use the IMAP or POP3 servers, don't activate them in the /etc/inetd.conf file.

The UW imapd server is now ready for use. You can connect to the Mac OS X machine to pick up e-mail that has been received by the Sendmail SMTP daemon.

Share ThisShare This

Informit Network