9.7. Post Office Servers
In this section we configure a system to act as a post office server. A post office server, or mailbox server, is a computer that holds mail for a client computer until the client is ready to download it for the mail reader. This service is essential to support mobile users and small systems that are frequently offline and thus not able to receive mail in real time. We look at two techniques for creating a post office server: Post Office Protocol (POP), which is the original protocol for this purpose, and Internet Message Access Protocol (IMAP), which is a popular alternative. We start with POP.
9.7.1. POP Server
A Unix host turns into a Post Office Protocol server when it runs a POP daemon. Check your system's documentation to see if a POP daemon is included in the system software. If it isn't clear from the documentation, check the inetd.conf or xinetd.conf file, or try the simple telnet test from Chapter 4, "Getting Started". If the server responds to the telnet test, not only is the daemon available on your system, it is installed and ready to run.
% telnet localhost 110 Trying 127.0.0.1 ... Connected to localhost. Escape character is ' ]'. +OK POP3 crab Server (Version 1.004) ready quit +OK POP3 crab Server (Version 1.001) shutdown Connection closed by foreign host.
This example is from a system that comes with POP3 ready to run. The Red Hat Linux system includes POP3, although it must be enabled in the /etc/xinetd.d/pop3 file before it can be used. The Solaris system, on the other hand, does not ship with POP2 or POP3. Don't worry if your system doesn't include this software. POP3 software is available from several sites on the Internet where it is stored in both the popper17.tar and the pop3d.tar files. I have used them both, and both work fine.
If you don't have POP3 on your system, download the source code. Extract it using the Unix tar command. pop3d.tar creates a directory called pop3d under the current directory, but popper17.tar does not. If you decide to use popper, create a new directory before extracting it with tar. Edit the Makefile to configure it for your system and do a make to compile the POP3 daemon. If it compiles without errors, install the daemon in a system directory.
On a Solaris system, POP3 is started by the Internet daemon, inetd. Start POP3 from inetd by placing the following in the inetd.conf file:
pop3 stream tcp nowait root /usr/sbin/pop3d pop3d
This entry assumes that you are using pop3d, that you placed the executable in the /usr/sbin directory, and that the port for this daemon is identified in the /etc/services file by the name pop3. If these things aren't true, adjust the entry accordingly.
Make sure that POP3 is actually defined in /etc/services. If it isn't, add the following line to that file:
pop3 110/tcp # Post Office Version 3
Once the lines are added to the services file and the inetd.conf file, send a SIGHUP to inetd to force it to read the new configuration, as in this example:
# ps -ef | grep inetd root 109 1 0 Jun 09 ? 0:01 /usr/sbin/inetd -s # kill -HUP 109
Now that POP3 is installed, rerun the test using telnet localhost pop3. If the POP3 daemon answers, you're in business. All users who have a valid user account on the system are now able to download mail via POP3 or read the mail directly on the server.
9.7.2. IMAP Server
Internet Message Access Protocol (IMAP) is an alternative to POP. It provides the same basic service as POP and adds features to support mailbox synchronization, which is the ability to read mail on a client or directly on the server while keeping the mailboxes on both systems completely up to date. On an average POP server, the entire contents of the mailbox are moved to the client and either deleted from the server or retained as if never read. Deletion of individual messages on the client is not reflected on the server because all the messages are treated as a single unit that is either deleted or retained after the initial transfer of data to the client. IMAP provides the ability to manipulate individual messages on either the client or the server and to have those changes reflected in the mailboxes of both systems.
IMAP is not a new protocol; it is about as old as POP3. There have been four distinct versions: IMAP, IMAP2, IMAP3, and the current version, IMAP4, which is defined in RFC 2060. IMAP is popular because of the importance of email as a means of communicating, even when people are out of the office, and the need for a mailbox that can be read and maintained from anywhere.
Solaris 8 does not include IMAP. IMAP binaries for Solaris are available from http://sunfreeware.com. IMAP source code can be obtained via anonymous FTP from ftp://ftp.cac.washington.edu. Download /mail/imap.tar.Z from ftp://ftp.cac.washington.edu as a binary image. Uncompress and untar the file. This creates a directory containing the source code and Makefile needed to build IMAP.
Read the Makefile carefully. It supports many versions of Unix. If you find yours listed, use the three-character operating system type listed there. For a Solaris system using the gcc compiler, enter:
# make gso
If it compiles without error, as it does on our Solaris system, it produces three daemons: ipop2d, ipop3d, and imapd. We are familiar with installing POP3. The new one is imapd. Install it in /etc/services:
imap 143/tcp # IMAP version 4
Also add it to /etc/inetd:
imap stream tcp nowait root /usr/sbin/imapd imapd
Now basic IMAP service is available to every user with an account on the server.
A nice feature of the University of Washington package is that it provides implementations of POP2 and POP3 as well as IMAP. This is important because many email clients run POP3. The IMAP server can be accessed only by an IMAP client. Installing POP3 along with IMAP gives you the chance to support the full range of clients.
Most Linux systems include IMAP, so compiling the source code is not a requirement. Simply make sure that the service is listed in the /etc/services file and available through inetd or xinetd. On Red Hat Linux 7, the /etc/xinetd.d/imap file is disabled by default and must be enabled to allow clients access to the service.
POP and IMAP are important components of a mail service. However, there is a great deal more to configuring a complete email system, as we will see in the next chapter.
Copyright © 2002 O'Reilly & Associates. All rights reserved.