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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap

Dev Shed Tutorial Topics: