Specifications

$header = imap_header($imap, $messageid);
if($header->reply_toaddress)
$to = $header->reply_toaddress;
else
$to = $header->fromaddress;
$subject = ‘Re: ‘.$header->subject;
$body = add_quoting(stripslashes(imap_body($imap, $messageid)));
imap_close($imap);
display_new_message_form($auth_user, $to, $cc, $subject, $body);
}
break; //note deliberately no ‘break’
}
case ‘forward’ :
{
//set message as quoted body of current message
if(!$imap)
$imap = open_mailbox($auth_user, $selected_account);
if($imap)
{
$header = imap_header($imap, $messageid);
$body = add_quoting(stripslashes(imap_body($imap, $messageid)));
$subject = ‘Fwd: ‘.$header->subject;
imap_close($imap);
display_new_message_form($auth_user, $to, $cc, $subject, $body);
}
break;
}
You can see that each of these options sets up the appropriate headers, applies formatting as
necessary, and calls the display_new_message_form() function to set up the form.
Thats the full set of functionality for our Web mail reader.
Extending the Project
There are many extensions or improvements you could make to this project. You can look to
the mail reader you normally use for inspiration, but some useful additions are the following:
Add the ability for users to register with this site. (You could reuse some of the code
from Chapter 24, Building User Authentication and Personalization, for this purpose.)
Many users have more than one email address; perhaps a personal address and a work
address. By moving their stored email address from the users table to the accounts table,
Building Practical PHP and MySQL Projects
P
ART V
652
33 7842 CH27 3/6/01 3:41 PM Page 652