Home arrow PHP arrow Handling Attachments in MIME Email with PHP

Handling Attachments in MIME Email with 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



Sending plain text email with PHP is a pretty simple task that can be tackled with minor efforts thanks mostly to the easy learning curve of its popular ďmail()Ē built-in function. You know, you code a simple script that sends email messages to a bunch of recipients. It feeds this function with the proper email headers and the text of the message andÖ voila! The script works like a charm, and best of all, it only took a few minutes to be developed.

However, things get slightly more complicated when it comes to sending email messages in HTML, or when itís necessary to work with attachments, since these tasks require the use of MIME, which is the mail extension that permits you to send messages formatted in HTML, include inline files, and so forth.

The good news concerning the use of MIME email with PHP is that you can develop your own reusable functions in order to send messages in HTML and handle a huge variety of attachments. You can also take advantage of the object-oriented paradigm and create a highly modular MIME mailer class that does all of this hard work for you.

In either case, in this group of tutorials youíll find useful material regarding the construction of an expansible PHP class that can be utilized to send MIME-compliant messages very easily and work with different types of attachments.

And speaking of sending MIME-compliant email messages, in the last article of this series I went through the development of a basic mailer class in PHP 4. It was capable of dispatching plain text messages to a specified recipient by way of an intuitive API. Indeed, the functionality of this class was pretty limited, since it wasnít capable of working with HTML messages or attachments.

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