Compared to sending mail, reading mail is a little more difficult. The main reason for this is because the syntax is a little weird at first, so you may need to keep referring back here. Note that the functionality shown here is designed for IMAP servers, but also works fine with POP3 and NNTP.
Author's Note: Although making your own applications is fun, don't be afraid to re-use what's already out there. For example, there's an excellent web mail package already available - check out SquirrelMail at www.squirrelmail.org
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!