Specifications

We will also give him the option of viewing detailed headers for a particular message. Viewing
the complete headers can tell you a lot about a message. You can see which machine the mail
came froma useful tool for tracking down spam. You can see which machine forwarded it
and at what time it reached each hostuseful for assigning blame for delayed messages. You
might also be able to see which email client the sender used if the application adds optional
information to the headers.
We have used a slightly different application architecture for this project. Instead of having a
set of scripts, one for each module, we have a slightly longer script, index.php, that works like
the event loop of a GUI-driven program. Each action we take on the site by pressing a button
will bring us back to index.php, but with a different parameter. Depending on the parameter,
different functions will be called to show the appropriate output to the user. The functions are
in function libraries, as usual.
This architecture is suitable for small applications such as this. It suits applications that are
very event driven, where user actions trigger functionality. Using a single event handler is not
very suitable for larger architectures or projects being worked on by a team.
A summary of the files in the Warm Mail project is shown in Table 27.1.
TABLE 27.1 Files in the Warm Mail Application
Name Type Description
index.php Application The main script that runs the entire application
include_fns.php Functions Collection of include files for this application
data_valid_fns.php Functions Collection of functions for validating input data
db_fns.php Functions Collection of functions for connecting to the
mail database
mail_fns.php Functions Collection of email-related functions for open-
ing mailboxes, reading mail, and so on
output_fns.php Functions Collection of functions for outputting HTML
user_auth_fns.php Functions Collection of functions for authenticating users
create_database.sql SQL SQL to set up the book_sc database and set up
a user
Lets go ahead and look at the application.
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
621
33 7842 CH27 3/6/01 3:41 PM Page 621