HomePHP Migrating Class Code for a MIME Email to PHP 5
Migrating Class Code for a MIME Email to PHP 5
Welcome to the final installment of the series, “Sending MIME email with PHP.” This series teaches you how to build a highly modular PHP class that can be used to send MIME-compliant email messages in plain text and HTML, while letting you work with file attachments as well. In this article, I'm going to migrate the source code from the previous article to PHP 5, taking full advantage of the new and improved features in the latest version of PHP.
One of the easiest tasks to perform with PHP is sending email to one or more recipients, thanks to its popular built-in “mail()” function. However, if you’re armed with the right background, it’s relatively simple to build an entire mailer class using this function, so that you can take advantage of the MIME extension.
This mail extension permits, among other things, sending messages in HTML format and handling different types of file attachments, which you’ve surely done hundreds of times before while using your favorite email client. Nonetheless, if you’re interested in learning how to do all of these useful things by utilizing a single PHP class, then start reading this group of articles!
At this point I'm assuming that you already read the last article of this series, so you’ll surely recall that I completed the development of a MIME mailer class provided with the capacity to sending email messages in HTML and plain text format. It also had the ability to handle a decent number of file attachments. While this mailer class can be used with small PHP applications, it lacks some important features related specifically to its object model, since it was built in PHP 4 from the very beginning.
So are you ready to learn how to port the full source code of this MIME mailer class to PHP 5? Let’s begin now!