BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/net/email/Bs_HtmlMime.class.php
BlueShoes Application Framework - net/email

Bs_HtmlMime

Bs_Object
   |
  +-- Bs_HtmlMime

Html/Mime class.

 

public class Bs_HtmlMime extends Bs_Object

Html/Mime class.
used to send emails with html/text combinations and attachements.maybe it can be used to receive emails also...features:-missing:-*******************************************************************************//example:$htmlMime =& new Bs_HtmlMime();//Read the image background.gif into $background$background = $htmlMime->get_file('background.gif');//Read the file test.zip into $attachment.$attachment = $htmlMime->get_file('example.zip');//If sending an html email, then these two variables specify the text and//html versions of the mail. Don't have to be named as these are. Just//make sure the names tie in to the $htmlMime->add_html() call further down.$text = $htmlMime->get_file('example.txt');$html = $htmlMime->get_file('example.html');//Add the text, html and embedded images. Each embedded image has to be added//using $htmlMime->add_html_image() BEFORE calling $htmlMime->add_html(). The name//of the image should match exactly (case-sensitive) to the name in the html.$htmlMime->add_html_image($background, 'background.gif', 'image/gif');$htmlMime->add_html($html, $text);//This is used to add an attachment to the email.$htmlMime->add_attachment($attachment, 'example.zip', 'application/zip');//Builds the message.$htmlMime->build_message();$smtp =& new Bs_Smtp();$smtp->host = 'your.mailserver.com';$smtp->addFrom('from@blueshoes.org', 'from');$smtp->addTo('la@la.com', 'la la');$smtp->subject = 'hello world';$smtp->message = &$htmlMime->mime;//now we have to copy some htmlMime headers over to the smtp object.//these are://'MIME-Version: 1.0';//'Content-Type', something like// multipart/mixed;'.CRLF.chr(9).'boundary="'.$boundary.'"';// text/plain;'.CRLF.chr(9).'charset="'.$this->charset.'"';//'Content-Transfer-Encoding', something like// 7bit// quoted-printable// base64if (!empty($htmlMime->headers)) {while (list($k) = each($htmlMime->headers)) {$smtp->setHeader(NULL, $htmlMime->headers[$k]);}}//let's send it.$status = $smtp->send();**********************************************************************************************************************************************************this class is based on (it is nearly only):* Title.........: HTML Mime Mail class* Version.......: 1.38* Author........: Richard Heyes <richard.heyes@heyes-computing.net>* Filename......: class.html.mime.mail.class* Last changed..: 28 August 2001* License.......: Free to use. If you find it useful* though, feel free to buy me something* from my wishlist :)* http://www.amazon.co.uk/exec/obidos/wishlist/S8H2UOGMPZK6what does 'free to use' mean? ...license stated at http://www.zend.com/apps.php?CID=169License: Postcard-ware (Version: 1.1)if there are license problems we can easily replace this code withanother class from http://www.zend.com/apps.php?CID=169or we write our own. i'd much prefer a simpler interface for the coder.***************************************************************************

Authors, ,
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_HtmlMime(string $headers)

Constructor.

Private Method Summary

void

set_body(string $text)

************************************
void

get_mime()

************************************
void

add_header()

************************************
void

set_charset(string $charset, string $raw)

************************************
void

get_file( $filename)

************************************
void

find_html_images( $images_dir)

************************************
void

add_html( $html, $text, string $images_dir)

************************************
void

add_html_image( $file, string $name, string $c_type)

************************************
void

add_attachment( $file, string $name, string $c_type)

************************************
void

quoted_printable_encode( $input, integer $line_max)

************************************
void

get_encoded_data( $data, $encoding)

************************************
void

build_html( $orig_boundary)

************************************
void

build_html_image( $i)

************************************
void

build_part( $input)

************************************
void

build_message(array $params)

************************************
void

send( $to_name, $to_addr, $from_name, $from_addr, string $subject, string $headers)

************************************
void

get_rfc822( $to_name, $to_addr, $from_name, $from_addr, string $subject, string $headers)

************************************

Private Field Summary

string

$mime

finally holds the complete email message
unknown

$html

unknown

$body

unknown

$do_html

unknown

$multipart

unknown

$html_text

unknown

$html_images

unknown

$image_types

unknown

$build_params

unknown

$headers

unknown

$parts

unknown

$charset

unknown

$charsetlist

Private Constant Summary

BS_HTMLMIME_VERSION >>4.0.$x$<< Warning: documentation is missing.
CRLF >>\n<< Warning: documentation is missing.
BS_HTMLMIME_CRLF >>\r\n<< Warning: documentation is missing.

Public Method Details

Bs_HtmlMime

public void Bs_HtmlMime( string $headers )

  Constructor.
* Constructor function. Sets the headers* if supplied.

Parameter
string $headers
Warning: documentation is missing.
Returns void


Private Method Details

set_body

private void set_body( string $text )

  ************************************
* Accessor function to set the body text.* Body text is used if it's not an html* mail being sent.**************************************

Parameter
string $text
Warning: documentation is missing.
Returns void


get_mime

private void get_mime( )

  ************************************
* Accessor function to return the mime* class variable. Purely for debug.**************************************

Returns void


add_header

private void add_header( )

  ************************************
* Function to set a header. Shouldn't* really be necessary as you could use* the constructor and send functions,* it's here nonetheless. Takes any number* of arguments, which can be either* strings or arrays full of strings.* this function is php4 only and will* return false otherwise. Will return* true upon finishing.**************************************

Returns void


set_charset

private void set_charset( string $charset, string $raw )

  ************************************
* Accessor function to set the content charset.** Function contributed by "Matt"**************************************

Parameter
string $charset
Warning: documentation is missing.
string $raw
Warning: documentation is missing.
Returns void


get_file

private void get_file( $filename )

  ************************************
* This function will read a file in* from a supplied filename and return* it. This can then be given as the first* argument of the the functions* add_html_image() or add_attachment().**************************************

Parameter
$filename
Warning: documentation is missing.
Returns void


find_html_images

private void find_html_images( $images_dir )

  ************************************
* Function for extracting images from* html source. This function will look* through the html code supplied by add_html()* and find any file that ends in one of the* extensions defined in $obj->image_types.* If the file exists it will read it in and* embed it, (not an attachment).** Function contributed by Dan Allen**************************************

Parameter
$images_dir
Warning: documentation is missing.
Returns void


add_html

private void add_html( $html, $text, string $images_dir )

  ************************************
* Adds a html part to the mail.* Also replaces image names with* content-id's.**************************************

Parameter
$html
Warning: documentation is missing.
$text
Warning: documentation is missing.
string $images_dir
Warning: documentation is missing.
Returns void


add_html_image

private void add_html_image( $file, string $name, string $c_type )

  ************************************
* Adds an image to the list of embedded* images.**************************************

Parameter
$file
Warning: documentation is missing.
string $name
Warning: documentation is missing.
string $c_type
Warning: documentation is missing.
Returns void


add_attachment

private void add_attachment( $file, string $name, string $c_type )

  ************************************
* Adds a file to the list of attachments.**************************************

Parameter
$file
Warning: documentation is missing.
string $name
Warning: documentation is missing.
string $c_type
Warning: documentation is missing.
Returns void


quoted_printable_encode

private void quoted_printable_encode( $input, integer $line_max )

  ************************************
* Encodes text to quoted printable standard.** Function contributed by Allan Hansen**************************************

Parameter
$input
Warning: documentation is missing.
integer $line_max
Warning: documentation is missing.
Returns void


get_encoded_data

private void get_encoded_data( $data, $encoding )

  ************************************
* Function to return encoded text/html* based upon the build params. Don't* like this function name :(**************************************

Parameter
$data
Warning: documentation is missing.
$encoding
Warning: documentation is missing.
Returns void


build_html

private void build_html( $orig_boundary )

  ************************************
* Builds html part of email.**************************************

Parameter
$orig_boundary
Warning: documentation is missing.
Returns void


build_html_image

private void build_html_image( $i )

  ************************************
* Builds an embedded image part of an* html mail.**************************************

Parameter
$i
Warning: documentation is missing.
Returns void


build_part

private void build_part( $input )

  ************************************
* Builds a single part of a multipart* message.**************************************

Parameter
$input
Warning: documentation is missing.
Returns void


build_message

private void build_message( array $params )

  ************************************
* Builds the multipart message from the* list ($this->_parts). $params is an* array of parameters that shape the building* of the message. Currently supported are:** $params['html_encoding'] - The type of encoding to use on html. Valid options are* "7bit", "quoted-printable" or "base64" (all without quotes).* 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable* $params['text_encoding'] - The type of encoding to use on plain text Valid options are* "7bit", "quoted-printable" or "base64" (all without quotes).* Default is 7bit* $params['text_wrap'] - The character count at which to wrap 7bit encoded data. By* default this is 998.**************************************

Parameter
array $params
Warning: documentation is missing.
Returns void


send

private void send( $to_name, $to_addr, $from_name, $from_addr, string $subject, string $headers )

  ************************************
* Sends the mail.not recommended. use the smtp class.**************************************

Parameter
$to_name
Warning: documentation is missing.
$to_addr
Warning: documentation is missing.
$from_name
Warning: documentation is missing.
$from_addr
Warning: documentation is missing.
string $subject
Warning: documentation is missing.
string $headers
Warning: documentation is missing.
Returns void


get_rfc822

private void get_rfc822( $to_name, $to_addr, $from_name, $from_addr, string $subject, string $headers )

  ************************************
* Use this method to return the email* in message/rfc822 format. Useful for* adding an email to another email as* an attachment. there's a commented* out example in example.php.** string get_rfc822(string To name,* string To email,* string From name,* string From email,* [string Subject,* string Extra headers])**************************************

Parameter
$to_name
Warning: documentation is missing.
$to_addr
Warning: documentation is missing.
$from_name
Warning: documentation is missing.
$from_addr
Warning: documentation is missing.
string $subject
Warning: documentation is missing.
string $headers
Warning: documentation is missing.
Returns void


Private Field Details

$mime

private string $mime

>><<

finally holds the complete email message
(after $this->build_message() has been called.)


$html

private unknown $html

>><<



$body

private unknown $body

>><<



$do_html

private unknown $do_html

>><<



$multipart

private unknown $multipart

>><<



$html_text

private unknown $html_text

>><<



$html_images

private unknown $html_images

>><<



$image_types

private unknown $image_types

>><<



$build_params

private unknown $build_params

>><<



$headers

private unknown $headers

>><<



$parts

private unknown $parts

>><<



$charset

private unknown $charset

>><<



$charsetlist

private unknown $charsetlist

>><<



Private Constant Details

BS_HTMLMIME_VERSION

define( BS_HTMLMIME_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



CRLF

define( CRLF, >>\n<< )
Case: case insensitive, userdefined: 'TRUE'



BS_HTMLMIME_CRLF

define( BS_HTMLMIME_CRLF, >>\r\n<< )
Case: case insensitive, userdefined: 'TRUE'




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta