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.

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

You can then extract each of the fields you require from the object:<br />

$message['subject'] = $header->subject;<br />

You call imap_body() to add the message body to the array as follows:<br />

$message['body'] = imap_body($imap, $messageid);<br />

Finally, you close the mailbox with imap_close() <strong>and</strong> return the array you have built.<br />

The display_message() function can then display the message’s fields in the form<br />

shown in Figure 29.6.<br />

Viewing Message Headers<br />

As you can see in Figure 29.6, the message contains a Show Headers button. It activates<br />

the show-headers option, which adds the full message headers to the message display. If<br />

the user clicks this button, he will see output similar to that shown in Figure 29.7.<br />

Figure 29.7 Using show-headers to see the full headers for this message<br />

will help a user track down the source of the spam.<br />

As you probably noticed, the event h<strong>and</strong>ling for view-message covers show-headers<br />

(<strong>and</strong> its counterpart hide-headers), too. If this option is selected, you do the same

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

Saved successfully!

Ooh no, something went wrong!