PHP
  Home arrow PHP arrow Page 4 - Migrating Class Code for a MIME Email to PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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

Migrating Class Code for a MIME Email to PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2008-08-06


    Table of Contents:
  • Migrating Class Code for a MIME Email to PHP 5
  • Sending MIME email with PHP 4
  • Porting the code of the previous MIME mailer class to PHP 5
  • Putting the brand new mailer class to work

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Migrating Class Code for a MIME Email to PHP 5 - Putting the brand new mailer class to work
    ( Page 4 of 4 )

    In accordance with the concepts expressed in the previous section, I’ve set up a practical example aimed at demonstrating the functionality offered by the MIME mailer class now that it has been migrated to PHP 5.

    The pertaining code sample looks like this:


    try{

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

    $mailer=new Mailer
    ('alejandro@mydomain.com','somebuddy@yourdomain.com,'Testing the mailer
    class','Hey, I am sending you a couple of fun images.');

    // add some HTML to the message

    $mailer->addHTML('<strong>This text is formatted with HTML</strong>');

    // add some attachments

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

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

    // send MIME email

    $mailer->send();

    }

    catch(Exception $e){

    echo $e->getMessage();

    exit();

    }


    As you can see, the API of the “Mailer” class allows us to send email messages in both plain text and HTML formats. And if all of these features aren’t good enough for you, it also handles file attachments in a simple way.

    Finally, I recommend you tweak the source code of this class and incorporate your own modifications in order to suit your personal requirements.

    Final thoughts

    It’s hard to believe, but we’ve come to the end of this journey. I hope the whole experience has been instructive, since I simply tried to provide you with some useful pointers to help you start using MIME email within your own PHP applications. In a case like this, I used an object-oriented approach to send email, but you can utilize a procedural methodology and obtain practically the same results.

    See you in the next PHP development tutorial!



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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT