HomePHP Composing Messages in HTML for MIME Email with PHP
Composing Messages in HTML for MIME Email with PHP
Welcome to the fourth episode of the series, "Sending MIME email with PHP." In this article, Iím going to show you how to provide the MIME mailer class with the ability to send email messages in HTML format. This will greatly extend its functionality, so don't miss this tutorial.
The Multipurpose Internet Mail Extension (short for MIME) permits, among other things, sending email messages in HTML format, working with different types of attached files, and so forth. But, the good news here is that you can use all the features offered by MIME directly with PHP. You can develop applications that dispatch MIME-compliant messages to a bunch of recipients.
Naturally, sending MIME email with PHP can be done using either a procedural or an object-oriented approach. If youíre interested in utilizing this latter, youíll find a friendly guide on building a highly modular MIME mailer class in this series of articles. It utilizes this extension in order to send messages in both plain text and HTML format. It also supports working with file attachments.
At this point, I should assume that youíre well aware of the goals of this series. Thus, itís an excellent time to rehash the topics covered in the last tutorial, in case you haven't had the chance to read it yet. In that particular article, I demonstrated how to improve the signature of the MIME mailer class that I built in the beginning of this series by adding a brand new property, called ď$mimeTypes,Ē to it. This helped store all the MIME types supported by the class, when dealing with file attachments.
Of course, after introducing this minor modification to the signature of the aforementioned mailer class, its whole structure looked more compact and more efficient. Nonetheless, my primary intention here is to teach you how to create an expansible PHP class that takes real advantage of the MIME extension.
With the preliminaries out of our way, letís jump forward and see how to add HTML capabilities to this MIME mailer class. Itís going to be an instructive experience!