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.

29<br />

Building a <strong>Web</strong>-Based<br />

Email Service<br />

MORE AND MORE OFTEN THESE DAYS, SITES WANT to offer web-based email to their<br />

users.This chapter explains how to implement a web interface to an existing mail server<br />

using the <strong>PHP</strong> IMAP library.You can use it to check your own existing mailbox through<br />

a web page or perhaps extend it to support many users for mass web-based email such as<br />

GMail,Yahoo! Mail, <strong>and</strong> Hotmail.<br />

In this project, you build an email client,Warm Mail, that will enable users to<br />

n Connect to their accounts on POP3 or IMAP mail servers<br />

n Read mail<br />

n Send mail<br />

n Reply to mail messages<br />

n Forward mail messages<br />

n Delete mail from their accounts<br />

Solution Components<br />

For a user to be able to read his mail, you need to find a way to connect to his mail<br />

server.This generally isn’t the same machine as the web server.You need a way to interact<br />

with the user’s mailbox to see what messages have been received <strong>and</strong> to deal with<br />

each message individually.<br />

Mail Protocols: POP3 Versus IMAP<br />

Two main protocols are supported by mail servers for reading user mailboxes: Post Office<br />

Protocol version 3 (POP3) <strong>and</strong> Internet Message Access Protocol (IMAP). If possible,<br />

you should support both of them.

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

Saved successfully!

Ooh no, something went wrong!