Ever wondered how Web-based mail clients work, or what happens toyour email after you hit the "Send" button? This three-part case studydelves into the wild and wacky world of Web-based email applications, usingPHP's built-in POP3 functions to build an email client suitable forrerieving POP3 email via a Web browser. In this introductory segment -connecting to a POP3 server, logging in and out, retrieving message headersfor display, and deleting messages off the server.
It's almost hard to believe that, up until a few years ago, putting pen to paper was still the most common method of corresponding with long-lost relatives or distant business partners. Today, email is all-pervasive - it has a user base ranging from doting grandmothers to over-enthusiastic dot-commers - and is, by far, the fastest, most efficient way to communicate. Arthur C. Clarke once said that any sufficiently advanced technology was indistinguishable from magic; with millions of messages criss-crossing the globe at any given time, email has some pretty potent magic of its own.
As a developer, email, and the systems designed to process it, have always fascinated me. Ever since I got my first email account, I've always found there to be something magical about the process by which a text message is encoded and bounced around the world from one mail server to another until it reaches its recipient, thence to be decoded back into its original form and displayed. And so, when I was offered the opportunity to work on a Web-based email client a few weeks back, I jumped at it; here, at last, was my chance to learn a little bit more about what actually happens after you hit the "Send" button...
As it turned out, building a mail client wasn't anywhere near as hard as I thought it would be...and with the help of powerful open-source tools like PHP, the process was simplified considerably. Over the course of this article, I'm going to demonstrate how, by building a PHP-based mail client suitable for reading and writing email in any Web browser.
The goal here is two-fold: to introduce novice and intermediate programmers to the process of designing and implementing a Web-based application, with special reference to PHP's mail functions, and to offer road warriors, network administrators, email buffs and other interested folk a functional (and fairly good-looking) email solution for use on their corporate intranet or Web site.