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

Putting the modified “Mailer” class to work - 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

Below I coded a final hands-on example that demonstrates how to use the “Mailer” class, after its original signature has been modified.

Here is the corresponding code sample:


// create a new instance of the 'Mailer' class

$mailer=&new Mailer('alejandro@mydomain.com,'mybuddy@yourdomain.com','Testing mailer class','Hello buddy. I am sending you a couple of fun images.');

// add some attachments

$mailer->addAttachment('file1.jpg');

$mailer->addAttachment('file.jpg');

// send MIME email

$mailer->send();


As you can see, changing the way  the “Mailer” class does some of its things doesn’t imply that its API must change too. The above example demonstrates this concept very clearly, since the steps taken to use the class in question are the same steps you learned in the two previous tutorials of the series.

And lastly, here’s my final suggestion: feel free to introduce your own modifications to the pertaining “Mailer” class, not only to extend its functionality, but to improve your background in sending MIME email with PHP.

Final thoughts

In this third episode of the series, I showed you how to improve the business logic of the previous MIME mailer class, specifically when it comes to determining the MIME type of the attached files. As you saw before, this process was performed by creating an additional array of class properties. So you shouldn’t have major problems understanding how it functions.

In the next article, I’m going to continue extending the functionality of this MIME mailer class by providing it with the capacity to send email messages in HTML format.

The article will be insightful, trust me. I hope you don’t miss the upcoming tutorial!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: