Specifications

echo “No mailbox selected<br><br><br><br><br><br>.”;
}
else
{
$imap = open_mailbox($auth_user, $accountid);
if($imap)
{
echo “<table width = $table_width cellspacing = 0
cellpadding = 6 border = 0>”;
$headers = imap_headers($imap);
// we could reformat this data, or get other details using
// imap_fetchheaders, but this is not a bad summary so we just echo each
$messages = sizeof($headers);
for($i = 0; $i<$messages; $i++)
{
echo “<tr><td bgcolor = ‘“;
if($i%2)
echo “#ffffff”;
else
echo “#ffffcc”;
echo “‘><a href =’index.php?action=view-
message&messageid=”.($i+1).”’>”;
echo $headers[$i];
echo “</a></td></tr>\n”;
}
echo “</table>”;
}
else
{
$account = get_account_settings($auth_user, $accountid);
echo “could not open mail box “.$account[‘server’].”.<br><br><br><br>”;
}
}
}
In this function, we actually begin to use PHPs IMAP functions. The two key parts of this
function are opening the mailbox and reading the message headers.
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
641
LISTING 27.8 Continued
33 7842 CH27 3/6/01 3:41 PM Page 641