Home arrow PHP arrow A Better Way to Determine MIME Types for MIME Email with PHP

A Better Way to Determine MIME Types for MIME Email with PHP

Welcome to the third episode of the series entitled “Sending MIME email with PHP.” This series progressively teaches you how to construct a reusable MIME mailer class that can be easily integrated into your existing PHP applications. In this article, I’ll be modifying the implementation of the “getMimeTypes()” method, included with this mailer class, in order to make it more compact and efficient.

  1. A Better Way to Determine MIME Types for MIME Email with PHP
  2. Review: sending MIME-compliant email messages with PHP 4
  3. Modifying the signature of the “Mailer” class
  4. Putting the modified “Mailer” class to work
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
July 23, 2008

print this article



If you’re a PHP developer who has spent a long time building web applications, then you’re probably aware of the remarkable capabilities offered by email. This capacity has been built around the PHP native “mail()” function, which, as you know, facilitates the development of email-related scripts.

However, this beautiful and peaceful scenario can quickly turn into a raging storm, specifically in those cases when you need to send email messages in HTML format and work with attachments. Here’s where MIME comes in handy, since this mail extension allows you to perform all of these tasks with minor hassles, even though it might take some time to master its most complex features.

However, if you’re interested in learning how to use an object-oriented approach to build a highly modular PHP class that sends fully-compliant MIME email messages, while also working with file attachments, you’ve come to the right place.

And now that you’ve been introduced to the principal subject of this PHP series, let me briefly refresh the topics that I discussed in the last article, in case that you’ve not had the chance to read it. In it, I demonstrated how to build a modular MIME mailer class in PHP 4; it was provided with the capacity to send messages in plain text, and to work with different types of file attachments.

This class implements a private method, called “getMimeTypes(),” which, as its name would suggest, comes in handy for determining the correct MIME type of a given file. As you know, this process is required to assemble the different parts of a multi-part MIME-based message correctly. However, the logic implemented by this method is rather primitive and can definitely be improved.

Are you ready to continue this educational journey? Let’s get started!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: