13.09.2016 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

As you can see, this function uses a number of the IMAP functions.The new ones are<br />

imap_delete() <strong>and</strong> imap_expunge(). Note that imap_delete() only marks messages<br />

for deletion.You can mark as many messages as you like.The call to imap_expunge()<br />

actually deletes the messages.<br />

Sending Mail<br />

Finally, we come to sending mail.You can do this in a few ways from this script:The user<br />

can send a new message, reply to, or forward mail. Let’s see how these actions work.<br />

Sending a New Message<br />

The user can choose to send a new message by clicking the New Message button.<br />

Doing so activates the ‘new-message’ action, which executes the following code in<br />

index.php/case 'new-message':<br />

display_new_message_form($_SESSION['auth_user'],<br />

$to, $cc, $subject, $body);<br />

break;<br />

The new message form is just a form for sending mail.You can see what it looks like in<br />

Figure 29.8.This figure actually shows a mail reply rather than new mail, but the form is<br />

the same.We look at forwarding <strong>and</strong> replies next.<br />

Figure 29.8<br />

You can reply to the message or forward it on to someone else.

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

Saved successfully!

Ooh no, something went wrong!