Specifications
Solution Components
PHP has excellent IMAP and POP3 support, but it is provided via the IMAP function library. In
order to use the code presented in this chapter, you will need to have installed the IMAP library.
You can tell if you already have this installed by looking at the output of the phpinfo() function.
If not, you will need to download the extension. You can get the latest version via FTP from
ftp://ftp.cac.washington.edu/imap/c-client.tar.Z
Under UNIX, download the source and compile it for your operating system. When you have
done this, copy rfc822.h, mail.h, and linkage.h to /usr/local/include or another direc-
tory in your include path, run PHP’s configure script, adding the --with-imap directive to any
other parameters you use, and recompile PHP.
Documentation exists on compiling the Windows version yourself, but it is much more com-
plex than compiling for UNIX. If you are using a Windows platform, there is an easier alterna-
tive. You can download a precompiled version of PHP compiled with various extensions,
including the IMAP extension, from
http://www.php4win.de
One interesting thing to note is that although these are called IMAP functions they also work
equally well with POP3 and NNTP (Network News Transfer Protocol). We will use them for
IMAP and POP3, but the Warm Mail application could be easily extended to use NNTP.
A very large number of functions are in this library, but in order to implement the functionality
in this application, we will use only a few. We’ll explain these functions as we use them, but be
aware that there are many more. See the documentation if your needs are different from ours,
or if you want to add extra features to the application.
You can build a fairly useful mail application with only a fraction of the built-in functions.
This means that you need only plow through a fraction of the documentation. The IMAP func-
tions we use in this chapter are
• imap_open()
• imap_close()
• imap_headers()
• imap_header()
• imap_fetchheader()
• imap_body()
• imap_delete()
• imap_expunge()
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
619
33 7842 CH27 3/6/01 3:41 PM Page 619










