Rmail Class Reference

o------------------------------------------------------------------------------o | This package is licensed under the Phpguru license. More...

List of all members.

Public Member Functions

 __construct ()
 Constructor function.
 setCRLF ($crlf="\n")
 Accessor to set the CRLF style.
 setSMTPParams ($host=null, $port=null, $helo=null, $auth=null, $user=null, $pass=null)
 Accessor to set the SMTP parameters.
 setSendmailPath ($path)
 Sets sendmail path and options (optionally) (when directly piping to sendmail).
 setTextEncoding (iEncoding $encoding)
 Accessor function to set the text encoding.
 setHTMLEncoding (iEncoding $encoding)
 Accessor function to set the HTML encoding.
 setTextCharset ($charset= 'ISO-8859-1')
 Accessor function to set the text charset.
 setHTMLCharset ($charset= 'ISO-8859-1')
 Accessor function to set the HTML charset.
 setHeadCharset ($charset= 'ISO-8859-1')
 Accessor function to set the header encoding charset.
 setTextWrap ($count=998)
 Accessor function to set the text wrap count.
 setHeader ($name, $value)
 Accessor to set a header.
 setReceipt ($email)
 Sets the delivery reciept address.
 setSubject ($subject)
 Accessor to add a Subject: header.
 setFrom ($from)
 Accessor to add a From: header.
 setPriority ($priority= 'normal')
 Accessor to set priority.
 setReturnPath ($return_path)
 Accessor to set the return path.
 setCc ($cc)
 Accessor to add a Cc: header.
 setBcc ($bcc)
 Accessor to add a Bcc: header.
 setText ($text)
 Adds plain text.
 setHTML ($html, $images_dir=null)
 Adds HTML to the emails, with an associated text part.
 addEmbeddedImage ($embeddedImage)
 Adds an image to the list of embedded images.
 addAttachment ($attachment)
 Adds a file to the list of attachments.
 send ($recipients, $type= 'mail')
 Sends the mail.
 getRFC822 ($recipients, $type= 'mail')
 Use this method to return the email in message/rfc822 format.

Private Member Functions

 findHtmlImages ($images_dir)
 Function for extracting images from html source.
 addTextPart (&$message)
 Adds a text subpart to a mime_part object.
 addHtmlPart (&$message)
 Adds a html subpart to a mime_part object.
 addMixedPart (&$message)
 Starts a message with a mixed part.
 addAlternativePart (&$message)
 Adds an alternative part to a mime_part object.
 addRelatedPart (&$message)
 Adds a html subpart to a mime_part object.
 addHtmlImageParts (&$message)
 Adds all html images to a mime_part object.
 addAttachmentParts (&$message)
 Adds all attachments to a mime_part object.
 build ()
 Builds the multipart message.
 encodeHeader ($input, $charset= 'ISO-8859-1')
 Function to encode a header if necessary according to RFC2047.

Private Attributes

 $html
 $text
 The text part of the message(only used in TEXT only messages) string.
 $output
 The main body of the message after building string.
 $html_images
 An array of embedded images /objects array.
 $image_types
 An array of recognised image types for the findHtmlImages() method array.
 $build_params
 Parameters that affect the build process array.
 $attachments
 Array of attachments array.
 $headers
 The main message headers array.
 $return_path
 The return path address.
 $smtp_params
 Array of information needed for smtp sending array.
 $sendmail_path
 Sendmail path.


Detailed Description

o------------------------------------------------------------------------------o | This package is licensed under the Phpguru license.

A quick summary is | | that for commercial use, there is a small one-time licensing fee to pay. For | | registered charities and educational institutes there is a reduced license | | fee available. You can read more at: | | | | http://www.phpguru.org/static/license.html | o------------------------------------------------------------------------------o

© Copyright 2008,2009 Richard Heyes

Definition at line 17 of file Rmail.php.


Constructor & Destructor Documentation

Rmail::__construct (  ) 

Constructor function.

Initialise some variables.

If you want the auto load functionality to find other image/file types, add the extension and content type here.

Set these up

Defaults for smtp sending

Make sure the MIME version header is first.

Definition at line 89 of file Rmail.php.

00090     {
00094         $this->attachments   = array();
00095         $this->html_images   = array();
00096         $this->headers       = array();
00097         $this->text          = '';
00098         $this->sendmail_path = '/usr/lib/sendmail -ti';
00099 
00105         $this->image_types = array('gif'  => 'image/gif',
00106                                    'jpg'  => 'image/jpeg',
00107                                    'jpeg' => 'image/jpeg',
00108                                    'jpe'  => 'image/jpeg',
00109                                    'bmp'  => 'image/bmp',
00110                                    'png'  => 'image/png',
00111                                    'tif'  => 'image/tiff',
00112                                    'tiff' => 'image/tiff',
00113                                    'swf'  => 'application/x-shockwave-flash');
00114 
00118         $this->build_params['html_encoding'] = new QPrintEncoding();
00119         $this->build_params['text_encoding'] = new SevenBitEncoding();
00120         $this->build_params['html_charset']  = 'ISO-8859-1';
00121         $this->build_params['text_charset']  = 'ISO-8859-1';
00122         $this->build_params['head_charset']  = 'ISO-8859-1';
00123         $this->build_params['text_wrap']     = 998;
00124 
00128         if (!empty($_SERVER['HTTP_HOST'])) {
00129             $helo = $_SERVER['HTTP_HOST'];
00130 
00131         } elseif (!empty($_SERVER['SERVER_NAME'])) {
00132             $helo = $_SERVER['SERVER_NAME'];
00133         
00134         } else {
00135             $helo = 'localhost';
00136         }
00137 
00138         $this->smtp_params['host'] = 'localhost';
00139         $this->smtp_params['port'] = 25;
00140         $this->smtp_params['helo'] = $helo;
00141         $this->smtp_params['auth'] = false;
00142         $this->smtp_params['user'] = '';
00143         $this->smtp_params['pass'] = '';
00144 
00148         $this->headers['MIME-Version'] = '1.0';
00149         $this->headers['X-Mailer'] = 'Rmail <http://www.phpguru.org/>';
00150     }


Member Function Documentation

Rmail::addAlternativePart ( &$  message  )  [private]

Adds an alternative part to a mime_part object.

Parameters:
object $obj
Returns:
object Mime part object

Definition at line 515 of file Rmail.php.

Referenced by build().

00516     {
00517         $params['content_type'] = 'multipart/alternative';
00518 
00519         if (!empty($message)) {
00520             return $message->addSubpart('', $params);
00521         } else {
00522             $message = new Mail_mimePart('', $params);
00523         }
00524     }

Rmail::addAttachment ( attachment  ) 

Adds a file to the list of attachments.

Parameters:
string $attachment Attachment object

Definition at line 454 of file Rmail.php.

References $attachment.

00455     {
00456         $this->attachments[] = $attachment;
00457     }

Rmail::addAttachmentParts ( &$  message  )  [private]

Adds all attachments to a mime_part object.

Parameters:
object $obj Message object

Definition at line 566 of file Rmail.php.

Referenced by build().

00567     {
00568         foreach ($this->attachments as $value) {
00569             $params['content_type'] = $value->contentType;
00570             $params['encoding']     = $value->encoding->getType();
00571             $params['disposition']  = 'attachment';
00572             $params['dfilename']    = $value->name;
00573         
00574             $message->addSubpart($value->data, $params);
00575         }
00576     }

Rmail::addEmbeddedImage ( embeddedImage  ) 

Adds an image to the list of embedded images.

Parameters:
string $object Embedded image object

Definition at line 441 of file Rmail.php.

Referenced by findHtmlImages().

00442     {
00443         $embeddedImage->cid = md5(uniqid(time()));
00444 
00445         $this->html_images[] = $embeddedImage;
00446     }

Rmail::addHtmlImageParts ( &$  message  )  [private]

Adds all html images to a mime_part object.

Parameters:
object $obj Message object

Definition at line 548 of file Rmail.php.

Referenced by build().

00549     {
00550         foreach ($this->html_images as $value) {
00551             $params['content_type'] = $value->contentType;
00552             $params['encoding']     = $value->encoding->getType();
00553             $params['disposition']  = 'inline';
00554             $params['dfilename']    = $value->name;
00555             $params['cid']          = $value->cid;
00556     
00557             $message->addSubpart($value->data, $params);
00558         }
00559     }

Rmail::addHtmlPart ( &$  message  )  [private]

Adds a html subpart to a mime_part object.

Parameters:
object $obj
Returns:
object Mime part object

Definition at line 484 of file Rmail.php.

Referenced by build().

00485     {
00486         $params['content_type'] = 'text/html';
00487         $params['encoding']     = $this->build_params['html_encoding']->getType();
00488         $params['charset']      = $this->build_params['html_charset'];
00489 
00490         if (!empty($message)) {
00491             $message->addSubpart($this->html, $params);
00492         } else {
00493             $message = new Mail_mimePart($this->html, $params);
00494         }
00495     }

Rmail::addMixedPart ( &$  message  )  [private]

Starts a message with a mixed part.

Returns:
object Mime part object

Definition at line 502 of file Rmail.php.

Referenced by build().

00503     {
00504         $params['content_type'] = 'multipart/mixed';
00505         
00506         $message = new Mail_mimePart('', $params);
00507     }

Rmail::addRelatedPart ( &$  message  )  [private]

Adds a html subpart to a mime_part object.

Parameters:
object $obj
Returns:
object Mime part object

Definition at line 532 of file Rmail.php.

Referenced by build().

00533     {
00534         $params['content_type'] = 'multipart/related';
00535 
00536         if (!empty($message)) {
00537             return $message->addSubpart('', $params);
00538         } else {
00539             $message = new Mail_mimePart('', $params);
00540         }
00541     }

Rmail::addTextPart ( &$  message  )  [private]

Adds a text subpart to a mime_part object.

Parameters:
object $obj
Returns:
object Mime part object

Definition at line 465 of file Rmail.php.

Referenced by build().

00466     {
00467         $params['content_type'] = 'text/plain';
00468         $params['encoding']     = $this->build_params['text_encoding']->getType();
00469         $params['charset']      = $this->build_params['text_charset'];
00470 
00471         if (!empty($message)) {
00472             $message->addSubpart($this->text, $params);
00473         } else {
00474             $message = new Mail_mimePart($this->text, $params);
00475         }
00476     }

Rmail::build (  )  [private]

Builds the multipart message.

Definition at line 581 of file Rmail.php.

References $attachments, $html, $html_images, $output, $text, addAlternativePart(), addAttachmentParts(), addHtmlImageParts(), addHtmlPart(), addMixedPart(), addRelatedPart(), and addTextPart().

Referenced by getRFC822(), and send().

00582     {
00583         if (!empty($this->html_images)) {
00584             foreach ($this->html_images as $value) {
00585                 $quoted = preg_quote($value->name);
00586                 $cid    = preg_quote($value->cid);
00587 
00588                 $this->html = preg_replace("#src=\"$quoted\"|src='$quoted'#", "src=\"cid:$cid\"", $this->html);
00589                 $this->html = preg_replace("#background=\"$quoted\"|background='$quoted'#", "background=\"cid:$cid\"", $this->html);
00590             }
00591         }
00592 
00593         $message     = null;
00594         $attachments = !empty($this->attachments);
00595         $html_images = !empty($this->html_images);
00596         $html        = !empty($this->html);
00597         $text        = !$html;
00598 
00599         switch (true) {
00600             case $text:
00601                 $message = null;
00602                 if ($attachments) {
00603                     $this->addMixedPart($message);
00604                 }
00605 
00606                 $this->addTextPart($message);
00607 
00608                 // Attachments
00609                 $this->addAttachmentParts($message);
00610                 break;
00611 
00612             case $html AND !$attachments AND !$html_images:
00613                 $this->addAlternativePart($message);
00614 
00615                 $this->addTextPart($message);
00616                 $this->addHtmlPart($message);
00617                 break;
00618 
00619             case $html AND !$attachments AND $html_images:
00620                 $this->addRelatedPart($message);
00621                 $alt = $this->addAlternativePart($message);
00622 
00623                 $this->addTextPart($alt);
00624                 $this->addHtmlPart($alt);
00625                 
00626                 // HTML images
00627                 $this->addHtmlImageParts($message);
00628                 break;
00629 
00630             case $html AND $attachments AND !$html_images:
00631                 $this->addMixedPart($message);
00632                 $alt = $this->addAlternativePart($message);
00633 
00634                 $this->addTextPart($alt);
00635                 $this->addHtmlPart($alt);
00636                 
00637                 // Attachments
00638                 $this->addAttachmentParts($message);
00639                 break;
00640 
00641             case $html AND $attachments AND $html_images:
00642                 $this->addMixedPart($message);
00643                 $rel = $this->addRelatedPart($message);
00644                 $alt = $this->addAlternativePart($rel);
00645                 
00646                 $this->addTextPart($alt);
00647                 $this->addHtmlPart($alt);
00648                 
00649                 // HTML images
00650                 $this->addHtmlImageParts($rel);
00651                 
00652                 // Attachments
00653                 $this->addAttachmentParts($message);
00654                 break;
00655 
00656         }
00657 
00658         if (isset($message)) {
00659             $output = $message->encode();
00660             $this->output   = $output['body'];
00661             $this->headers  = array_merge($this->headers, $output['headers']);
00662 
00663             // Figure out hostname
00664             if (!empty($_SERVER['HTTP_HOST'])) {
00665                 $hostname = $_SERVER['HTTP_HOST'];
00666             
00667             } else if (!empty($_SERVER['SERVER_NAME'])) {
00668                 $hostname = $_SERVER['SERVER_NAME'];
00669             
00670             } else if (!empty($_ENV['HOSTNAME'])) {
00671                 $hostname = $_ENV['HOSTNAME'];
00672             
00673             } else {
00674                 $hostname = 'localhost';
00675             }
00676             
00677             $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), $hostname);
00678             $this->headers['Message-ID'] = $message_id;
00679 
00680             return true;
00681         } else {
00682             return false;
00683         }
00684     }

Rmail::encodeHeader ( input,
charset = 'ISO-8859-1' 
) [private]

Function to encode a header if necessary according to RFC2047.

Parameters:
string $input Value to encode
string $charset Character set to use
Returns:
string Encoded value

Definition at line 694 of file Rmail.php.

Referenced by send().

00695     {
00696         preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $input, $matches);
00697         foreach ($matches[1] as $value) {
00698             $replacement = preg_replace('/([\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value);
00699             $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);
00700         }
00701         
00702         return $input;
00703     }

Rmail::findHtmlImages ( images_dir  )  [private]

Function for extracting images from html source.

This function will look through the html code supplied by setHTML() 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).

Parameters:
string $images_dir Images directory to look in

Go thru found images

Definition at line 402 of file Rmail.php.

References $html_images, and addEmbeddedImage().

Referenced by setHTML().

00403     {
00404         // Build the list of image extensions
00405         $extensions = array_keys($this->image_types);
00406 
00407         preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches);
00408 
00409         foreach ($matches[1] as $m) {
00410             if (file_exists($images_dir . $m)) {
00411                 $html_images[] = $m;
00412                 $this->html = str_replace($m, basename($m), $this->html);
00413             }
00414         }
00415 
00419         if (!empty($html_images)) {
00420 
00421             // If duplicate images are embedded, they may show up as attachments, so remove them.
00422             $html_images = array_unique($html_images);
00423             sort($html_images);
00424 
00425             foreach ($html_images as $img) {
00426                 if ($image = file_get_contents($images_dir . $img)) {
00427                     $ext          = preg_replace('#^.*\.(\w{3,4})$#e', 'strtolower("$1")', $img);
00428                     $content_type = $this->image_types[$ext];
00429                     $this->addEmbeddedImage(new stringEmbeddedImage($image, basename($img), $content_type));
00430                 }
00431             }
00432         }
00433     }

Rmail::getRFC822 ( recipients,
type = 'mail' 
)

Use this method to return the email in message/rfc822 format.

Useful for adding an email to another email as an attachment.

Parameters:
array $recipients Array of recipients
string $type Method to be used to send the mail. Used to determine the line ending type.

Definition at line 840 of file Rmail.php.

References $headers, build(), setCRLF(), and setHeader().

00841     {
00842         // Make up the date header as according to RFC822
00843         $this->setHeader('Date', date('D, d M y H:i:s O'));
00844 
00845         if (!defined('CRLF')) {
00846             $this->setCRLF($type == 'mail' ? "\n" : "\r\n");
00847         }
00848 
00849         $this->build();
00850 
00851         // Return path ?
00852         if (isset($this->return_path)) {
00853             $headers[] = 'Return-Path: ' . $this->return_path;
00854         }
00855 
00856         // Get flat representation of headers
00857         foreach ($this->headers as $name => $value) {
00858             $headers[] = $name . ': ' . $value;
00859         }
00860         $headers[] = 'To: ' . implode(', ', $recipients);
00861 
00862         return implode(CRLF, $headers) . CRLF . CRLF . $this->output;
00863     }

Rmail::send ( recipients,
type = 'mail' 
)

Sends the mail.

Parameters:
array $recipients Array of receipients to send the mail to
string $type How to send the mail ('mail' or 'sendmail' or 'smtp')
Returns:
mixed

Definition at line 712 of file Rmail.php.

References $address, $headers, $result, build(), smtp::connect(), encodeHeader(), Mail_RFC822::parseAddressList(), and setCRLF().

00713     {
00714         if (!defined('CRLF')) {
00715             $this->setCRLF( ($type == 'mail' OR $type == 'sendmail') ? "\n" : "\r\n");
00716         }
00717 
00718         $this->build();
00719 
00720         switch ($type) {
00721             case 'mail':
00722                 $subject = '';
00723                 if (!empty($this->headers['Subject'])) {
00724                     $subject = $this->encodeHeader($this->headers['Subject'], $this->build_params['head_charset']);
00725                     unset($this->headers['Subject']);
00726                 }
00727 
00728                 // Get flat representation of headers
00729                 foreach ($this->headers as $name => $value) {
00730                     $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
00731                 }
00732 
00733                 $to = $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
00734 
00735                 if (!empty($this->return_path)) {
00736                     $result = mail($to, $subject, $this->output, implode(CRLF, $headers), '-f' . $this->return_path);
00737                 } else {
00738                     $result = mail($to, $subject, $this->output, implode(CRLF, $headers));
00739                 }
00740 
00741                 // Reset the subject in case mail is resent
00742                 if ($subject !== '') {
00743                     $this->headers['Subject'] = $subject;
00744                 }
00745 
00746 
00747                 // Return
00748                 return $result;
00749                 break;
00750 
00751             case 'sendmail':
00752                 // Get flat representation of headers
00753                 foreach ($this->headers as $name => $value) {
00754                     $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
00755                 }
00756 
00757                 // Encode To:
00758                 $headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
00759 
00760                 // Get return path arg for sendmail command if necessary
00761                 $returnPath = '';
00762                 if (!empty($this->return_path)) {
00763                     $returnPath = '-f' . $this->return_path;
00764                 }
00765 
00766                 $pipe = popen($this->sendmail_path . " " . $returnPath, 'w');
00767                     $bytes = fputs($pipe, implode(CRLF, $headers) . CRLF . CRLF . $this->output);
00768                 $r = pclose($pipe);
00769 
00770                 return $r;
00771                 break;
00772 
00773             case 'smtp':
00774                 require_once(dirname(__FILE__) . '/smtp.php');
00775                 require_once(dirname(__FILE__) . '/RFC822.php');
00776                 $smtp = &smtp::connect($this->smtp_params);
00777                 
00778                 // Parse recipients argument for internet addresses
00779                 foreach ($recipients as $recipient) {
00780                     $addresses = Mail_RFC822::parseAddressList($recipient, $this->smtp_params['helo'], null, false);
00781                     foreach ($addresses as $address) {
00782                         $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
00783                     }
00784                 }
00785                 unset($addresses); // These are reused
00786                 unset($address);   // These are reused
00787 
00788                 // Get flat representation of headers, parsing
00789                 // Cc and Bcc as we go
00790                 foreach ($this->headers as $name => $value) {
00791                     if ($name == 'Cc' OR $name == 'Bcc') {
00792                         $addresses = Mail_RFC822::parseAddressList($value, $this->smtp_params['helo'], null, false);
00793                         foreach ($addresses as $address) {
00794                             $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
00795                         }
00796                     }
00797                     if ($name == 'Bcc') {
00798                         continue;
00799                     }
00800                     $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
00801                 }
00802                 // Add To header based on $recipients argument
00803                 $headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
00804 
00805                 // Add headers to send_params
00806                 $send_params['headers']    = $headers;
00807                 $send_params['recipients'] = array_values(array_unique($smtp_recipients));
00808                 $send_params['body']       = $this->output;
00809 
00810                 // Setup return path
00811                 if (isset($this->return_path)) {
00812                     $send_params['from'] = $this->return_path;
00813                 } elseif (!empty($this->headers['From'])) {
00814                     $from = Mail_RFC822::parseAddressList($this->headers['From']);
00815                     $send_params['from'] = sprintf('%s@%s', $from[0]->mailbox, $from[0]->host);
00816                 } else {
00817                     $send_params['from'] = 'postmaster@' . $this->smtp_params['helo'];
00818                 }
00819 
00820                 // Send it
00821                 if (!$smtp->send($send_params)) {
00822                     $this->errors = $smtp->getErrors();
00823                     return false;
00824                 }
00825                 return true;
00826                 break;
00827         }
00828     }

Rmail::setBcc ( bcc  ) 

Accessor to add a Bcc: header.

Parameters:
string $bcc Blind Carbon Copy address

Definition at line 358 of file Rmail.php.

00359     {
00360         $this->headers['Bcc'] = $bcc;
00361     }

Rmail::setCc ( cc  ) 

Accessor to add a Cc: header.

Parameters:
string $cc Carbon Copy address

Definition at line 348 of file Rmail.php.

00349     {
00350         $this->headers['Cc'] = $cc;
00351     }

Rmail::setCRLF ( crlf = "\n"  ) 

Accessor to set the CRLF style.

Parameters:
string $crlf CRLF style to use. Use
for SMTP, and
for normal.

Definition at line 159 of file Rmail.php.

Referenced by getRFC822(), and send().

00160     {
00161         if (!defined('CRLF')) {
00162             define('CRLF', $crlf, true);
00163         }
00164 
00165         if (!defined('MAIL_MIMEPART_CRLF')) {
00166             define('MAIL_MIMEPART_CRLF', $crlf, true);
00167         }
00168     }

Rmail::setFrom ( from  ) 

Accessor to add a From: header.

Parameters:
string $from From address

Definition at line 298 of file Rmail.php.

00299     {
00300         $this->headers['From'] = $from;
00301     }

Rmail::setHeadCharset ( charset = 'ISO-8859-1'  ) 

Accessor function to set the header encoding charset.

Parameters:
string $charset Character set to use

Definition at line 245 of file Rmail.php.

00246     {
00247         $this->build_params['head_charset'] = $charset;
00248     }

Rmail::setHeader ( name,
value 
)

Accessor to set a header.

Parameters:
string $name Name of header
string $value Value of header

Definition at line 266 of file Rmail.php.

Referenced by getRFC822().

00267     {
00268         $this->headers[$name] = $value;
00269     }

Rmail::setHTML ( html,
images_dir = null 
)

Adds HTML to the emails, with an associated text part.

If third part is given, images in the email will be loaded from this directory.

Parameters:
string $html HTML part of email
string $images_dir Images directory

Definition at line 382 of file Rmail.php.

References $html, and findHtmlImages().

00383     {
00384         $this->html = $html;
00385 
00386         if (!empty($images_dir)) {
00387             $this->findHtmlImages($images_dir);
00388         }
00389     }

Rmail::setHTMLCharset ( charset = 'ISO-8859-1'  ) 

Accessor function to set the HTML charset.

Parameters:
string $charset Character set to use

Definition at line 235 of file Rmail.php.

00236     {
00237         $this->build_params['html_charset'] = $charset;
00238     }

Rmail::setHTMLEncoding ( iEncoding encoding  ) 

Accessor function to set the HTML encoding.

Parameters:
object $encoding HTML encoding to use

Definition at line 215 of file Rmail.php.

00216     {
00217         $this->build_params['html_encoding'] = $encoding;
00218     }

Rmail::setPriority ( priority = 'normal'  ) 

Accessor to set priority.

Priority given should be either high, normal or low. Can also be specified numerically, being 1, 3 or 5 (respectively).

Parameters:
mixed $priority The priority to use.

Definition at line 310 of file Rmail.php.

00311     {
00312         switch (strtolower($priority)) {
00313             case 'high':
00314             case '1':
00315                 $this->headers['X-Priority'] = '1';
00316                 $this->headers['X-MSMail-Priority'] = 'High';
00317                 break;
00318 
00319             case 'normal':
00320             case '3':
00321                 $this->headers['X-Priority'] = '3';
00322                 $this->headers['X-MSMail-Priority'] = 'Normal';
00323                 break;
00324 
00325             case 'low':
00326             case '5':
00327                 $this->headers['X-Priority'] = '5';
00328                 $this->headers['X-MSMail-Priority'] = 'Low';
00329                 break;
00330         }
00331     }

Rmail::setReceipt ( email  ) 

Sets the delivery reciept address.

Parameters:
string $email The address you want the delivery reciept sent to. Note that this is sent at the discretion of the recipient

Definition at line 278 of file Rmail.php.

00279     {
00280         $this->headers['Disposition-Notification-To'] = $email;
00281     }

Rmail::setReturnPath ( return_path  ) 

Accessor to set the return path.

Parameters:
string $return_path Return path to use

Definition at line 338 of file Rmail.php.

References $return_path.

00339     {
00340         $this->return_path = $return_path;
00341     }

Rmail::setSendmailPath ( path  ) 

Sets sendmail path and options (optionally) (when directly piping to sendmail).

Parameters:
string $path Path and options for sendmail command

Definition at line 195 of file Rmail.php.

00196     {
00197         $this->sendmail_path = $path;
00198     }

Rmail::setSMTPParams ( host = null,
port = null,
helo = null,
auth = null,
user = null,
pass = null 
)

Accessor to set the SMTP parameters.

Parameters:
string $host Hostname
string $port Port
string $helo HELO string to use
bool $auth User authentication or not
string $user Username
string $pass Password

Definition at line 180 of file Rmail.php.

00181     {
00182         if (!is_null($host)) $this->smtp_params['host'] = $host;
00183         if (!is_null($port)) $this->smtp_params['port'] = $port;
00184         if (!is_null($helo)) $this->smtp_params['helo'] = $helo;
00185         if (!is_null($auth)) $this->smtp_params['auth'] = $auth;
00186         if (!is_null($user)) $this->smtp_params['user'] = $user;
00187         if (!is_null($pass)) $this->smtp_params['pass'] = $pass;
00188     }

Rmail::setSubject ( subject  ) 

Accessor to add a Subject: header.

Parameters:
string $subject Subject to set

Definition at line 288 of file Rmail.php.

00289     {
00290         $this->headers['Subject'] = $subject;
00291     }

Rmail::setText ( text  ) 

Adds plain text.

Use this function when NOT sending html email

Parameters:
string $text Plain text of email

Definition at line 369 of file Rmail.php.

References $text.

00370     {
00371         $this->text = $text;
00372     }

Rmail::setTextCharset ( charset = 'ISO-8859-1'  ) 

Accessor function to set the text charset.

Parameters:
string $charset Character set to use

Definition at line 225 of file Rmail.php.

00226     {
00227         $this->build_params['text_charset'] = $charset;
00228     }

Rmail::setTextEncoding ( iEncoding encoding  ) 

Accessor function to set the text encoding.

Parameters:
object $encoding Text encoding to use

Definition at line 205 of file Rmail.php.

00206     {
00207         $this->build_params['text_encoding'] = $encoding;
00208     }

Rmail::setTextWrap ( count = 998  ) 

Accessor function to set the text wrap count.

Parameters:
integer $count Point at which to wrap text

Definition at line 255 of file Rmail.php.

00256     {
00257         $this->build_params['text_wrap'] = $count;
00258     }


Member Data Documentation

Rmail::$attachments [private]

Array of attachments array.

Definition at line 59 of file Rmail.php.

Referenced by build().

Rmail::$build_params [private]

Parameters that affect the build process array.

Definition at line 53 of file Rmail.php.

Rmail::$headers [private]

The main message headers array.

Definition at line 65 of file Rmail.php.

Referenced by getRFC822(), and send().

Rmail::$html [private]

Definition at line 23 of file Rmail.php.

Referenced by build(), and setHTML().

Rmail::$html_images [private]

An array of embedded images /objects array.

Definition at line 41 of file Rmail.php.

Referenced by build(), and findHtmlImages().

Rmail::$image_types [private]

An array of recognised image types for the findHtmlImages() method array.

Definition at line 47 of file Rmail.php.

Rmail::$output [private]

The main body of the message after building string.

Definition at line 35 of file Rmail.php.

Referenced by build().

Rmail::$return_path [private]

The return path address.

If not set the From: address is used instead string

Definition at line 72 of file Rmail.php.

Referenced by setReturnPath().

Rmail::$sendmail_path [private]

Sendmail path.

Do not include -f $sendmail_path

Definition at line 84 of file Rmail.php.

Rmail::$smtp_params [private]

Array of information needed for smtp sending array.

Definition at line 78 of file Rmail.php.

Rmail::$text [private]

The text part of the message(only used in TEXT only messages) string.

Definition at line 29 of file Rmail.php.

Referenced by build(), and setText().


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:50 2009 for fareofficelib by  doxygen 1.5.8