Specifications

create table accounts
(
username char(16) not null,
server char(100) not null,
port int not null,
type char(4) not null,
remoteuser char(50) not null,
remotepassword char(50) not null,
accountid int unsigned not null auto_increment primary key
);
grant select, insert, update, delete
on mail.*
to mail@localhost identified by ‘password’;
Remember that you can execute this SQL by typing
mysql -u root -p < create_database.sql
You will need to supply your root password. You should change the password for the mail user
in create_database.sql and in db_fns.php before running it.
On the CD-ROM, we have also provided an SQL file called populate.sql. In this application,
we are not going to create a user registration or administration process. You can add one your-
self if you want to use this software on a larger scale, but if you want it for personal use, you
will just need to insert yourself into the database. The populate.sql script provides a pro-
forma for doing this, so insert your details into it and run it to set yourself up as a user.
Script Architecture
As we mentioned before, this application uses one script to control everything. This script is
called index.php. It is shown in Listing 27.2. This script is quite long, but we will go through
it section by section.
LISTING 27.2 index.phpThe Backbone of the Warm Mail System
<?
// This file is the main body of the Warm Mail application.
// It works basically as a state machine and shows users the
// output for the action they have chosen
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
623
LISTING 27.1 Continued
33 7842 CH27 3/6/01 3:41 PM Page 623