Home arrow PHP arrow Page 4 - Handling Attachments in MIME Email with PHP

Seeing the Mailer class in action - PHP

In this second tutorial of the series, Iím going to teach you how to improve the initial structure of the MIME mailer class developed in the first article by giving it the ability to work directly with attachments. Sounds fairly interesting, right? Then donít waste any more time in preliminaries and begin reading this article now!

  1. Handling Attachments in MIME Email with PHP
  2. Developing a simple MIME mailer class with PHP 4
  3. Working with email attachments
  4. Seeing the Mailer class in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
July 16, 2008

print this article



I listed the complete definition of this improved MIME ďMailerĒ class below along with a short script that demonstrates how to use it to send a trivial message that incorporates a pair of attached files.

Hereís 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. Is everything doing fine over there?');

// add some attachments



// send MIME email


Thatís all the source code that you need to get the ďMailerĒ class working as expected. For this particular case, I utilized the class to send a simple message in plain text along with a couple of attached GIF files. This should clearly show its considerable functionality.

As always, youíre free to use the code samples shown in this tutorial in case you want to use the previous ďMailerĒ class to improve your existing skills in sending MIME email with PHP.

Final thoughts

Thatís all for the moment. In this second chapter of the series, I taught you how to extend the existing functionality of the previous MIME mailer class in order to provide it with the capacity to work with attachments.

In the next tutorial, Iím going to improve the business logic implemented by the class, particularly when it comes to determining the MIME type of an attached file. This will make it slightly more compact and efficient.

Now that youíve been warned about the subject of the upcoming article, you wonít want to miss it!

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