HomePHP Page 7 - Building A PHP-Based Mail Client (part 2)
Miles To Go - PHP
Now that you've got a basic mail reader up and running, it's timeto learn a little more about attachments. This second segment analyzesMIME-encoded attachments, demonstrating how to decode and download them,and then integrates attachment handling features into the primitive mailclient previously demonstrated.
At this point, I'm fairly pleased with myself. I've succeeded in writing a fully-functional POP3 mail reader, one which is capable of connecting to any POP3 server, retrieving messages from it, and handling MIME-compliant attachments gracefully. Sure, it's not perfect - I've noticed problems with certain types of messages - but those are easily handled by appropriate additions to the parse() function, or by additional checks in "view.php", and you may even decide to ignore them if you're happy with the way the program currently works.
Hopefully, you've also learned a lot more about PHP's IMAP functions. This article introduced you to a few more important pieces of the puzzle, demonstrating how PHP's IMAP functions allow you to obtain detailed structural information on an email message, and extract individual segments from it for further processing. It also provided a crash course on MIME, using examples and theory to set the base for a practical implementation of MIME-based attachment handling.
We're now a lot closer to the end of this case study - all that's left is to write code to handle the four additional functions of compose, reply, forward and send. Come back for the final segment of this case study, and find out more about how I plan to handle these functions, together with a look at the process of constructing a MIME message and a brief discussion of the error handler used throughout this article.
Note: All examples in this article have been tested on Linux/ig86 with Apache 1.3.12 and PHP 4.0.6. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!