Specifications
The line
$fullheaders = ($action==’show-headers’);
could have been more verbosely—and perhaps more clearly—written as
if($action==’show-headers’)
$fullheaders = true;
else
$fullheaders = false;
Next, we call the display_message() function. Most of this function outputs plain HTML, so
we will not go through it here. It calls the retrieve_message() function to get the appropriate
message from the mailbox:
$message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
The retrieve_message() function is in the mail_fns.php library. You can see the code for it
in Listing 27.10.
LISTING 27.10 retrieve_message() Function from mail_fns.php—This Function Retrieves
One Specific Message from a Mailbox
function retrieve_message($auth_user, $accountid, $messageid, $fullheaders)
{
$message = array();
if(!($auth_user && $messageid && $accountid))
return false;
$imap = open_mailbox($auth_user, $accountid);
if(!$imap)
return false;
$header = imap_header($imap, $messageid);
if(!$header)
return false;
$message[‘body’] = imap_body($imap, $messageid);
if(!$message[‘body’])
$message[‘body’] = ‘[This message has no body]\n\n\n\n\n\n’;
if($fullheaders)
$message[‘fullheaders’] = imap_fetchheader($imap, $messageid);
else
$message[‘fullheaders’] = ‘’;
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
645
33 7842 CH27 3/6/01 3:41 PM Page 645