email.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: email.php 8248 2009-07-22 16:04:53Z DarkAngelBGE $ */
00003 /**
00004  * Short description for file.
00005  *
00006  * Long description for file
00007  *
00008  * PHP versions 4 and 5
00009  *
00010  * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
00011  * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00012  *
00013  * Licensed under The MIT License
00014  * Redistributions of files must retain the above copyright notice.
00015  *
00016  * @filesource
00017  * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00018  * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00019  * @package       cake
00020  * @subpackage    cake.cake.libs.controller.components
00021  * @since         CakePHP(tm) v 1.2.0.3467
00022  * @version       $Revision: 8248 $
00023  * @modifiedby    $LastChangedBy: DarkAngelBGE $
00024  * @lastmodified  $Date: 2009-07-22 12:04:53 -0400 (Wed, 22 Jul 2009) $
00025  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
00026  */
00027 /**
00028  * EmailComponent
00029  *
00030  * This component is used for handling Internet Message Format based
00031  * based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt
00032  *
00033  * @package       cake
00034  * @subpackage    cake.cake.libs.controller.components
00035  *
00036  */
00037 App::import('Core', 'Multibyte');
00038 class EmailComponent extends Object{
00039 /**
00040  * Recipient of the email
00041  *
00042  * @var string
00043  * @access public
00044  */
00045     var $to = null;
00046 /**
00047  * The mail which the email is sent from
00048  *
00049  * @var string
00050  * @access public
00051  */
00052     var $from = null;
00053 /**
00054  * The email the recipient will reply to
00055  *
00056  * @var string
00057  * @access public
00058  */
00059     var $replyTo = null;
00060 /**
00061  * The read receipt email
00062  *
00063  * @var string
00064  * @access public
00065  */
00066     var $readReceipt = null;
00067 /**
00068  * The mail that will be used in case of any errors like
00069  * - Remote mailserver down
00070  * - Remote user has exceeded his quota
00071  * - Unknown user
00072  *
00073  * @var string
00074  * @access public
00075  */
00076     var $return = null;
00077 /**
00078  * Carbon Copy
00079  *
00080  * List of email's that should receive a copy of the email.
00081  * The Recipient WILL be able to see this list
00082  *
00083  * @var array
00084  * @access public
00085  */
00086     var $cc = array();
00087 /**
00088  * Blind Carbon Copy
00089  *
00090  * List of email's that should receive a copy of the email.
00091  * The Recipient WILL NOT be able to see this list
00092  *
00093  * @var array
00094  * @access public
00095  */
00096     var $bcc = array();
00097 /**
00098  * The subject of the email
00099  *
00100  * @var string
00101  * @access public
00102  */
00103     var $subject = null;
00104 /**
00105  * Associative array of a user defined headers
00106  * Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
00107  *
00108  * @var array
00109  * @access public
00110  */
00111     var $headers = array();
00112 /**
00113  * List of additional headers
00114  *
00115  * These will NOT be used if you are using safemode and mail()
00116  *
00117  * @var string
00118  * @access public
00119  */
00120     var $additionalParams = null;
00121 /**
00122  * Layout for the View
00123  *
00124  * @var string
00125  * @access public
00126  */
00127     var $layout = 'default';
00128 /**
00129  * Template for the view
00130  *
00131  * @var string
00132  * @access public
00133  */
00134     var $template = null;
00135 /**
00136  * as per RFC2822 Section 2.1.1
00137  *
00138  * @var integer
00139  * @access public
00140  */
00141     var $lineLength = 70;
00142 /**
00143  * @deprecated see lineLength
00144  */
00145     var $_lineLength = null;
00146 /**
00147  * What format should the email be sent in
00148  *
00149  * Supported formats:
00150  * - text
00151  * - html
00152  * - both
00153  *
00154  * @var string
00155  * @access public
00156  */
00157     var $sendAs = 'text';
00158 /**
00159  * What method should the email be sent by
00160  *
00161  * Supported methods:
00162  * - mail
00163  * - smtp
00164  * - debug
00165  *
00166  * @var string
00167  * @access public
00168  */
00169     var $delivery = 'mail';
00170 /**
00171  * charset the email is sent in
00172  *
00173  * @var string
00174  * @access public
00175  */
00176     var $charset = 'utf-8';
00177 /**
00178  * List of files that should be attached to the email.
00179  *
00180  * Can be both absolute and relative paths
00181  *
00182  * @var array
00183  * @access public
00184  */
00185     var $attachments = array();
00186 /**
00187  * What mailer should EmailComponent identify itself as
00188  *
00189  * @var string
00190  * @access public
00191  */
00192     var $xMailer = 'CakePHP Email Component';
00193 /**
00194  * The list of paths to search if an attachment isnt absolute
00195  *
00196  * @var array
00197  * @access public
00198  */
00199     var $filePaths = array();
00200 /**
00201  * List of options to use for smtp mail method
00202  *
00203  * Options is:
00204  * - port
00205  * - host
00206  * - timeout
00207  * - username
00208  * - password
00209  *
00210  * @var array
00211  * @access public
00212  */
00213     var $smtpOptions = array(
00214         'port'=> 25, 'host' => 'localhost', 'timeout' => 30
00215     );
00216 /**
00217  * Placeholder for any errors that might happen with the
00218  * smtp mail methods
00219  *
00220  * @var string
00221  * @access public
00222  */
00223     var $smtpError = null;
00224 /**
00225  * If set to true, the mail method will be auto-set to 'debug'
00226  *
00227  * @var string
00228  * @access protected
00229  */
00230     var $_debug = false;
00231 /**
00232  * Temporary store of message header lines
00233  *
00234  * @var array
00235  * @access private
00236  */
00237     var $__header = array();
00238 /**
00239  * If set, boundary to use for multipart mime messages
00240  *
00241  * @var string
00242  * @access private
00243  */
00244     var $__boundary = null;
00245 /**
00246  * Temporary store of message lines
00247  *
00248  * @var array
00249  * @access private
00250  */
00251     var $__message = array();
00252 /**
00253  * Variable that holds SMTP connection
00254  *
00255  * @var resource
00256  * @access private
00257  */
00258     var $__smtpConnection = null;
00259 /**
00260  * Initialize component
00261  *
00262  * @param object $controller Instantiating controller
00263  * @access public
00264  */
00265     function initialize(&$controller, $settings = array()) {
00266         $this->Controller =& $controller;
00267         if (Configure::read('App.encoding') !== null) {
00268             $this->charset = Configure::read('App.encoding');
00269         }
00270         $this->_set($settings);
00271     }
00272 /**
00273  * Startup component
00274  *
00275  * @param object $controller Instantiating controller
00276  * @access public
00277  */
00278     function startup(&$controller) {}
00279 /**
00280  * Send an email using the specified content, template and layout
00281  *
00282  * @param mixed $content Either an array of text lines, or a string with contents
00283  * @param string $template Template to use when sending email
00284  * @param string $layout Layout to use to enclose email body
00285  * @return boolean Success
00286  * @access public
00287  */
00288     function send($content = null, $template = null, $layout = null) {
00289         $this->__createHeader();
00290 
00291         if ($template) {
00292             $this->template = $template;
00293         }
00294 
00295         if ($layout) {
00296             $this->layout = $layout;
00297         }
00298 
00299         if (is_array($content)) {
00300             $content = implode("\n", $content) . "\n";
00301         }
00302 
00303         $message = $this->__wrap($content);
00304         if ($this->template === null) {
00305             $message = $this->__formatMessage($message);
00306         } else {
00307             $message = $this->__renderTemplate($message);
00308         }
00309         $message[] = '';
00310         $this->__message = $message;
00311 
00312         if (!empty($this->attachments)) {
00313             $this->__attachFiles();
00314         }
00315 
00316         if (!is_null($this->__boundary)) {
00317             $this->__message[] = '';
00318             $this->__message[] = '--' . $this->__boundary . '--';
00319             $this->__message[] = '';
00320         }
00321 
00322         if ($this->_debug) {
00323             return $this->__debug();
00324         }
00325         $__method = '__' . $this->delivery;
00326         $sent = $this->$__method();
00327 
00328         $this->__header = array();
00329         $this->__message = array();
00330 
00331         return $sent;
00332     }
00333 /**
00334  * Reset all EmailComponent internal variables to be able to send out a new email.
00335  *
00336  * @access public
00337  */
00338     function reset() {
00339         $this->template = null;
00340         $this->to = null;
00341         $this->from = null;
00342         $this->replyTo = null;
00343         $this->return = null;
00344         $this->cc = array();
00345         $this->bcc = array();
00346         $this->subject = null;
00347         $this->additionalParams = null;
00348         $this->smtpError = null;
00349         $this->attachments = array();
00350         $this->__header = array();
00351         $this->__boundary = null;
00352         $this->__message = array();
00353     }
00354 /**
00355  * Render the contents using the current layout and template.
00356  *
00357  * @param string $content Content to render
00358  * @return array Email ready to be sent
00359  * @access private
00360  */
00361     function __renderTemplate($content) {
00362         $viewClass = $this->Controller->view;
00363 
00364         if ($viewClass != 'View') {
00365             if (strpos($viewClass, '.') !== false) {
00366                 list($plugin, $viewClass) = explode('.', $viewClass);
00367             }
00368             $viewClass = $viewClass . 'View';
00369             App::import('View', $this->Controller->view);
00370         }
00371         $View = new $viewClass($this->Controller, false);
00372         $View->layout = $this->layout;
00373         $msg = array();
00374 
00375         $content = implode("\n", $content);
00376 
00377         if ($this->sendAs === 'both') {
00378             $htmlContent = $content;
00379             if (!empty($this->attachments)) {
00380                 $msg[] = '--' . $this->__boundary;
00381                 $msg[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
00382                 $msg[] = '';
00383             }
00384             $msg[] = '--alt-' . $this->__boundary;
00385             $msg[] = 'Content-Type: text/plain; charset=' . $this->charset;
00386             $msg[] = 'Content-Transfer-Encoding: 7bit';
00387             $msg[] = '';
00388 
00389             $content = $View->element('email' . DS . 'text' . DS . $this->template, array('content' => $content), true);
00390             $View->layoutPath = 'email' . DS . 'text';
00391             $content = explode("\n", str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));
00392             $msg = array_merge($msg, $content);
00393 
00394             $msg[] = '';
00395             $msg[] = '--alt-' . $this->__boundary;
00396             $msg[] = 'Content-Type: text/html; charset=' . $this->charset;
00397             $msg[] = 'Content-Transfer-Encoding: 7bit';
00398             $msg[] = '';
00399 
00400             $htmlContent = $View->element('email' . DS . 'html' . DS . $this->template, array('content' => $htmlContent), true);
00401             $View->layoutPath = 'email' . DS . 'html';
00402             $htmlContent = explode("\n", str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($htmlContent)));
00403             $msg = array_merge($msg, $htmlContent);
00404             $msg[] = '';
00405             $msg[] = '--alt-' . $this->__boundary . '--';
00406             $msg[] = '';
00407 
00408             return $msg;
00409         }
00410 
00411         if (!empty($this->attachments)) {
00412             if ($this->sendAs === 'html') {
00413                 $msg[] = '';
00414                 $msg[] = '--' . $this->__boundary;
00415                 $msg[] = 'Content-Type: text/html; charset=' . $this->charset;
00416                 $msg[] = 'Content-Transfer-Encoding: 7bit';
00417                 $msg[] = '';
00418             } else {
00419                 $msg[] = '--' . $this->__boundary;
00420                 $msg[] = 'Content-Type: text/plain; charset=' . $this->charset;
00421                 $msg[] = 'Content-Transfer-Encoding: 7bit';
00422                 $msg[] = '';
00423             }
00424         }
00425 
00426         $content = $View->element('email' . DS . $this->sendAs . DS . $this->template, array('content' => $content), true);
00427         $View->layoutPath = 'email' . DS . $this->sendAs;
00428         $content = explode("\n", str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));
00429         $msg = array_merge($msg, $content);
00430 
00431         return $msg;
00432     }
00433 /**
00434  * Create unique boundary identifier
00435  *
00436  * @access private
00437  */
00438     function __createBoundary() {
00439         $this->__boundary = md5(uniqid(time()));
00440     }
00441 /**
00442  * Create emails headers including (but not limited to) from email address, reply to,
00443  * bcc and cc.
00444  *
00445  * @access private
00446  */
00447     function __createHeader() {
00448         if ($this->delivery == 'smtp') {
00449             $this->__header[] = 'To: ' . $this->__formatAddress($this->to);
00450         }
00451         $this->__header[] = 'From: ' . $this->__formatAddress($this->from);
00452 
00453         if (!empty($this->replyTo)) {
00454             $this->__header[] = 'Reply-To: ' . $this->__formatAddress($this->replyTo);
00455         }
00456         if (!empty($this->return)) {
00457             $this->__header[] = 'Return-Path: ' . $this->__formatAddress($this->return);
00458         }
00459         if (!empty($this->readReceipt)) {
00460             $this->__header[] = 'Disposition-Notification-To: ' . $this->__formatAddress($this->readReceipt);
00461         }
00462 
00463         if (!empty($this->cc)) {
00464             $this->__header[] = 'cc: ' .implode(', ', array_map(array($this, '__formatAddress'), $this->cc));
00465         }
00466 
00467         if (!empty($this->bcc) && $this->delivery != 'smtp') {
00468             $this->__header[] = 'Bcc: ' .implode(', ', array_map(array($this, '__formatAddress'), $this->bcc));
00469         }
00470         if ($this->delivery == 'smtp') {
00471             $this->__header[] = 'Subject: ' . $this->__encode($this->subject);
00472         }
00473         $this->__header[] = 'X-Mailer: ' . $this->xMailer;
00474 
00475         if (!empty($this->headers)) {
00476             foreach ($this->headers as $key => $val) {
00477                 $this->__header[] = 'X-' . $key . ': ' . $val;
00478             }
00479         }
00480 
00481         if (!empty($this->attachments)) {
00482             $this->__createBoundary();
00483             $this->__header[] = 'MIME-Version: 1.0';
00484             $this->__header[] = 'Content-Type: multipart/mixed; boundary="' . $this->__boundary . '"';
00485             $this->__header[] = 'This part of the E-mail should never be seen. If';
00486             $this->__header[] = 'you are reading this, consider upgrading your e-mail';
00487             $this->__header[] = 'client to a MIME-compatible client.';
00488         } elseif ($this->sendAs === 'text') {
00489             $this->__header[] = 'Content-Type: text/plain; charset=' . $this->charset;
00490         } elseif ($this->sendAs === 'html') {
00491             $this->__header[] = 'Content-Type: text/html; charset=' . $this->charset;
00492         } elseif ($this->sendAs === 'both') {
00493             $this->__header[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
00494         }
00495 
00496         $this->__header[] = 'Content-Transfer-Encoding: 7bit';
00497     }
00498 /**
00499  * Format the message by seeing if it has attachments.
00500  *
00501  * @param string $message Message to format
00502  * @access private
00503  */
00504     function __formatMessage($message) {
00505         if (!empty($this->attachments)) {
00506             $prefix = array('--' . $this->__boundary);
00507             if ($this->sendAs === 'text') {
00508                 $prefix[] = 'Content-Type: text/plain; charset=' . $this->charset;
00509             } elseif ($this->sendAs === 'html') {
00510                 $prefix[] = 'Content-Type: text/html; charset=' . $this->charset;
00511             } elseif ($this->sendAs === 'both') {
00512                 $prefix[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
00513             }
00514             $prefix[] = 'Content-Transfer-Encoding: 7bit';
00515             $prefix[] = '';
00516             $message = array_merge($prefix, $message);
00517         }
00518         return $message;
00519     }
00520 /**
00521  * Attach files by adding file contents inside boundaries.
00522  *
00523  * @access private
00524  * @TODO: modify to use the core File class?
00525  */
00526     function __attachFiles() {
00527         $files = array();
00528         foreach ($this->attachments as $attachment) {
00529             $file = $this->__findFiles($attachment);
00530             if (!empty($file)) {
00531                 $files[] = $file;
00532             }
00533         }
00534 
00535         foreach ($files as $file) {
00536             $handle = fopen($file, 'rb');
00537             $data = fread($handle, filesize($file));
00538             $data = chunk_split(base64_encode($data)) ;
00539             fclose($handle);
00540 
00541             $this->__message[] = '--' . $this->__boundary;
00542             $this->__message[] = 'Content-Type: application/octet-stream';
00543             $this->__message[] = 'Content-Transfer-Encoding: base64';
00544             $this->__message[] = 'Content-Disposition: attachment; filename="' . basename($file) . '"';
00545             $this->__message[] = '';
00546             $this->__message[] = $data;
00547             $this->__message[] = '';
00548         }
00549     }
00550 /**
00551  * Find the specified attachment in the list of file paths
00552  *
00553  * @param string $attachment Attachment file name to find
00554  * @return string Path to located file
00555  * @access private
00556  */
00557     function __findFiles($attachment) {
00558         if (file_exists($attachment)) {
00559             return $attachment;
00560         }
00561         foreach ($this->filePaths as $path) {
00562             if (file_exists($path . DS . $attachment)) {
00563                 $file = $path . DS . $attachment;
00564                 return $file;
00565             }
00566         }
00567         return null;
00568     }
00569 /**
00570  * Wrap the message using EmailComponent::$lineLength
00571  *
00572  * @param string $message Message to wrap
00573  * @return array Wrapped message
00574  * @access private
00575  */
00576     function __wrap($message) {
00577         $message = $this->__strip($message, true);
00578         $message = str_replace(array("\r\n","\r"), "\n", $message);
00579         $lines = explode("\n", $message);
00580         $formatted = array();
00581 
00582         if ($this->_lineLength !== null) {
00583             trigger_error('_lineLength cannot be accessed please use lineLength', E_USER_WARNING);
00584             $this->lineLength = $this->_lineLength;
00585         }
00586 
00587         foreach ($lines as $line) {
00588             if (substr($line, 0, 1) == '.') {
00589                 $line = '.' . $line;
00590             }
00591             $formatted = array_merge($formatted, explode("\n", wordwrap($line, $this->lineLength, "\n", true)));
00592         }
00593         $formatted[] = '';
00594         return $formatted;
00595     }
00596 /**
00597  * Encode the specified string using the current charset
00598  *
00599  * @param string $subject String to encode
00600  * @return string Encoded string
00601  * @access private
00602  */
00603     function __encode($subject) {
00604         $subject = $this->__strip($subject);
00605 
00606         $nl = "\r\n";
00607         if ($this->delivery == 'mail') {
00608             $nl = '';
00609         }
00610         return mb_encode_mimeheader($subject, $this->charset, 'B', $nl);
00611     }
00612 /**
00613  * Format a string as an email address
00614  *
00615  * @param string $string String representing an email address
00616  * @return string Email address suitable for email headers or smtp pipe
00617  * @access private
00618  */
00619     function __formatAddress($string, $smtp = false) {
00620         if (strpos($string, '<') !== false) {
00621             $value = explode('<', $string);
00622             if ($smtp) {
00623                 $string = '<' . $value[1];
00624             } else {
00625                 $string = $this->__encode($value[0]) . ' <' . $value[1];
00626             }
00627         }
00628         return $this->__strip($string);
00629     }
00630 /**
00631  * Remove certain elements (such as bcc:, to:, %0a) from given value
00632  *
00633  * @param string $value Value to strip
00634  * @param boolean $message Set to true to indicate main message content
00635  * @return string Stripped value
00636  * @access private
00637  */
00638     function __strip($value, $message = false) {
00639         $search  = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:';
00640         $search .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
00641 
00642         if ($message !== true) {
00643             $search .= '|\r|\n';
00644         }
00645         $search = '#(?:' . $search . ')#i';
00646         while (preg_match($search, $value)) {
00647             $value = preg_replace($search, '', $value);
00648         }
00649         return $value;
00650     }
00651 /**
00652  * Wrapper for PHP mail function used for sending out emails
00653  *
00654  * @return bool Success
00655  * @access private
00656  */
00657     function __mail() {
00658         $header = implode("\n", $this->__header);
00659         $message = implode("\n", $this->__message);
00660         if (ini_get('safe_mode')) {
00661             return @mail($this->to, $this->__encode($this->subject), $message, $header);
00662         }
00663         return @mail($this->to, $this->__encode($this->subject), $message, $header, $this->additionalParams);
00664     }
00665 /**
00666  * Sends out email via SMTP
00667  *
00668  * @return bool Success
00669  * @access private
00670  */
00671     function __smtp() {
00672         App::import('Core', array('Socket'));
00673 
00674         $this->__smtpConnection =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->smtpOptions));
00675 
00676         if (!$this->__smtpConnection->connect()) {
00677             $this->smtpError = $this->__smtpConnection->lastError();
00678             return false;
00679         } elseif (!$this->__smtpSend(null, '220')) {
00680             return false;
00681         }
00682 
00683         if (isset($this->smtpOptions['client'])) {
00684             $host = $this->smtpOptions['client'];
00685         } else {
00686             $host = env('HTTP_HOST');
00687         }
00688 
00689         if (!$this->__smtpSend("HELO {$host}", '250')) {
00690             return false;
00691         }
00692 
00693         if (isset($this->smtpOptions['username']) && isset($this->smtpOptions['password'])) {
00694             $authRequired = $this->__smtpSend('AUTH LOGIN', '334|503');
00695             if ($authRequired == '334') {
00696                 if (!$this->__smtpSend(base64_encode($this->smtpOptions['username']), '334')) {
00697                     return false;
00698                 }
00699                 if (!$this->__smtpSend(base64_encode($this->smtpOptions['password']), '235')) {
00700                     return false;
00701                 }
00702             } elseif ($authRequired != '503') {
00703                 return false;
00704             }
00705         }
00706 
00707         if (!$this->__smtpSend('MAIL FROM: ' . $this->__formatAddress($this->from, true))) {
00708             return false;
00709         }
00710 
00711         if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($this->to, true))) {
00712             return false;
00713         }
00714 
00715         foreach ($this->cc as $cc) {
00716             if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($cc, true))) {
00717                 return false;
00718             }
00719         }
00720         foreach ($this->bcc as $bcc) {
00721             if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($bcc, true))) {
00722                 return false;
00723             }
00724         }
00725 
00726         if (!$this->__smtpSend('DATA', '354')) {
00727             return false;
00728         }
00729 
00730         $header = implode("\r\n", $this->__header);
00731         $message = implode("\r\n", $this->__message);
00732         if (!$this->__smtpSend($header . "\r\n\r\n" . $message . "\r\n\r\n\r\n.")) {
00733             return false;
00734         }
00735         $this->__smtpSend('QUIT', false);
00736 
00737         $this->__smtpConnection->disconnect();
00738         return true;
00739     }
00740 /**
00741  * Private method for sending data to SMTP connection
00742  *
00743  * @param string $data data to be sent to SMTP server
00744  * @param mixed $checkCode code to check for in server response, false to skip
00745  * @return bool Success
00746  * @access private
00747  */
00748     function __smtpSend($data, $checkCode = '250') {
00749         if (!is_null($data)) {
00750             $this->__smtpConnection->write($data . "\r\n");
00751         }
00752         if ($checkCode !== false) {
00753             $response = $this->__smtpConnection->read();
00754 
00755             if (preg_match('/^(' . $checkCode . ')/', $response, $code)) {
00756                 return $code[0];
00757             }
00758             $this->smtpError = $response;
00759             return false;
00760         }
00761         return true;
00762     }
00763 /**
00764  * Set as controller flash message a debug message showing current settings in component
00765  *
00766  * @return boolean Success
00767  * @access private
00768  */
00769     function __debug() {
00770         $nl = "\n";
00771         $header = implode($nl, $this->__header);
00772         $message = implode($nl, $this->__message);
00773         $fm = '<pre>';
00774 
00775         if ($this->delivery == 'smtp') {
00776             $fm .= sprintf('%s %s%s', 'Host:', $this->smtpOptions['host'], $nl);
00777             $fm .= sprintf('%s %s%s', 'Port:', $this->smtpOptions['port'], $nl);
00778             $fm .= sprintf('%s %s%s', 'Timeout:', $this->smtpOptions['timeout'], $nl);
00779         }
00780         $fm .= sprintf('%s %s%s', 'To:', $this->to, $nl);
00781         $fm .= sprintf('%s %s%s', 'From:', $this->from, $nl);
00782         $fm .= sprintf('%s %s%s', 'Subject:', $this->__encode($this->subject), $nl);
00783         $fm .= sprintf('%s%3$s%3$s%s', 'Header:', $header, $nl);
00784         $fm .= sprintf('%s%3$s%3$s%s', 'Parameters:', $this->additionalParams, $nl);
00785         $fm .= sprintf('%s%3$s%3$s%s', 'Message:', $message, $nl);
00786         $fm .= '</pre>';
00787 
00788         $this->Controller->Session->setFlash($fm, 'default', null, 'email');
00789         return true;
00790     }
00791 
00792 }
00793 ?>

Generated on Sun Nov 22 00:30:53 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7