Specifications

Sending Mail with Attachments
For this project, we would like to be able to send users either a plain text newsletter or a
fancyHTML version, according to their preference.
To send an HTML file with embedded images, we will need to find a way to send attachments.
PHPs simple mail() function doesnt easily support sending attachments. Instead, we will use
the excellent HTML MIME Mail class created by Richard Heyes. This can deal with HTML
attachments, and will automatically attach any images that are contained in the HTML file.
You can get the most up-to-date version of this class from
http://www.heyes-computing.net/scripts/
(Its also on the CD-ROM in this book.)
You are free to use this script in your own work. It is released as Postcard-Ware. If you use it,
send the author a post card. The address is on his Web site.
Solution Overview
For this project, we will again use an event-driven approach to writing our code, as we did in
Chapter 27, Building a Web-Based Email Service.
We have again begun by drawing a set of system flow diagrams to show the paths users might
take through the system. In this case, we have drawn three diagrams to represent the three dif-
ferent sets of interactions users can have with the system. Users have different allowable
actions when they are not logged in, when they are logged in as regular users, and when they
are logged in as administrators. These actions are shown in Figures 28.1, 28.2, and 28.3,
respectively.
Building Practical PHP and MySQL Projects
P
ART V
658
Show
all lists
Not
logged in
Login
New
Account
FIGURE 28.1
A user can only choose a limited number of actions when he is not logged in.
34 7842 CH28 3/6/01 3:46 PM Page 658