PHP
  Home arrow PHP arrow Page 4 - Composing Messages in HTML for MIME Email with PHP
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

Composing Messages in HTML for MIME Email with PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2008-07-30


    Table of Contents:
  • Composing Messages in HTML for MIME Email with PHP
  • Review: sending MIME-compliant messages in plain text format
  • Sending email messages in HTML format
  • Sending email in HTML format using the MIME mailer class

  • 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


    Composing Messages in HTML for MIME Email with PHP - Sending email in HTML format using the MIME mailer class
    ( Page 4 of 4 )

    Below I coded a basic script, which comes in handy for illustrating the functionality of the “Mailer” class, especially when it comes to sending email messages in HTML.

    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. I am sending to you a couple of fun images.');

    $mailer->addHTML('<p>This is a simple paragraph formatted in HTML</p>');

    $mailer->addHTML('<p>This is another paragraph formatted in HTML</p>');

    // add some attachments

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

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

    // send MIME email

    $mailer->send();


    As shown in the above example, I used the MIME mailer class to send a simple text message with a couple of attached files. However, I’m also sending HTML code embedded into the message in question.

    As usual, I suggest you to test the previous “Mailer” class by incorporating your own improvements. It’s going to be an educational experience, trust me!

    Final thoughts

    That’s all for now. In this fourth installment of the series, I taught you how to build a modular MIME mailer class that’s capable of sending email in both plain text and HTML formats. In addition, the class supports working with file attachments, so I guess it should be quite helpful when it comes to learning the basics of sending MIME email with PHP.

    In the last chapter, I’ll be porting the complete source code of the class to PHP 5. This will take advantage of its improved object model. Don’t miss the upcoming article!



     
     
    >>> 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 6 Hosted by Hostway
    Stay green...Green IT