PHP
  Home arrow PHP arrow Page 4 - Handling Attachments in MIME Email wit...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Handling Attachments in MIME Email with PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-07-16

    Table of Contents:
  • Handling Attachments in MIME Email with PHP
  • Developing a simple MIME mailer class with PHP 4
  • Working with email attachments
  • Seeing the Mailer class in action

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Handling Attachments in MIME Email with PHP - Seeing the Mailer class in action


    (Page 4 of 4 )

    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

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

    $mailer->addAttachment('file2.gif');

    // send MIME email

    $mailer->send();


    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!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This second tutorial of the series shows how to improve the initial structure of the...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT