13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

674 Chapter 29 Building a <strong>Web</strong>-Based Email Service<br />

Viewing Mailbox Contents<br />

Mailbox contents can be viewed with the display_list() function.This function displays<br />

a list of all the messages in the mailbox.The code for this function is shown in<br />

Listing 29.8.<br />

Listing 29.8 display_list() Function from output_fns.php—Function to<br />

Display All Mailbox Messages<br />

function display_list($auth_user, $accountid) {<br />

// show the list of messages in this mailbox<br />

global $table_width;<br />

if(!$accountid) {<br />

echo "No mailbox selected.";<br />

} else {<br />

$imap = open_mailbox($auth_user, $accountid);<br />

if($imap) {<br />

echo "";<br />

$headers = imap_headers($imap);<br />

// we could reformat this data, or get other details using<br />

// imap_fetchheaders, but this is not a bad summary so we<br />

// just echo each<br />

$messages = sizeof($headers);<br />

for($i = 0; $i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!