2006-09-11 20:06:01 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2007-02-02 10:39:45 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
2006-09-11 20:06:01 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2007-02-02 10:39:45 +00:00
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
2006-09-11 20:06:01 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller.components
|
2007-02-02 10:39:45 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.3467
|
2006-09-11 20:06:01 +00:00
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller.components
|
|
|
|
*
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
class EmailComponent extends Object{
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $to = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $from = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $replyTo = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $return = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $cc = array();
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $bcc = array();
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $subject = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
var $additionalParams = null;
|
2007-04-03 01:15:24 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $layout = 'default';
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $template = 'default';
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
var $sendAs = 'text'; //html, text, both
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
var $delivery = 'mail'; //mail, smtp, debug
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $charset = 'ISO-8859-15';
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $attachments = array();
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
var $xMailer = 'CakePHP Email Component';
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $filePaths = array();
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $_debug = false;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $_error = false;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access protected
|
|
|
|
*/
|
2007-02-01 20:11:28 +00:00
|
|
|
var $_newLine = "\n";
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var integer
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-09-11 20:37:13 +00:00
|
|
|
var $_lineLength = 75;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $__header = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
var $__boundary = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 01:55:32 +00:00
|
|
|
var $__message = null;
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $controller
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
function startup(&$controller){
|
2007-04-03 01:15:24 +00:00
|
|
|
$this->Controller = & $controller;
|
2006-12-25 06:39:02 +00:00
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param mixed $content
|
|
|
|
* @return unknown
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
function send($content = null){
|
|
|
|
$this->__createHeader();
|
2007-03-28 22:57:07 +00:00
|
|
|
$this->subject = $this->__encode($this->subject);
|
2006-09-12 00:26:50 +00:00
|
|
|
|
|
|
|
if($this->template === null) {
|
2006-09-12 01:55:32 +00:00
|
|
|
if(is_array($content)){
|
|
|
|
$message = null;
|
|
|
|
foreach ($content as $key => $value){
|
|
|
|
$message .= $value . $this->_newLine;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$message = $content;
|
|
|
|
}
|
2006-12-25 06:39:02 +00:00
|
|
|
$this->__formatMessage($message);
|
2006-09-12 00:26:50 +00:00
|
|
|
} else {
|
2006-12-25 06:39:02 +00:00
|
|
|
$this->__message = $this->__renderTemplate($content);
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
2006-09-21 08:49:18 +00:00
|
|
|
if(!empty($this->attachments)) {
|
2006-09-12 00:26:50 +00:00
|
|
|
$this->__attachFiles();
|
|
|
|
}
|
2006-12-25 06:39:02 +00:00
|
|
|
|
2007-02-01 20:11:28 +00:00
|
|
|
if (!is_null($this->__boundary)) {
|
2007-03-08 02:01:29 +00:00
|
|
|
$this->__message .= $this->_newLine .'--' . $this->__boundary . '--' . $this->_newLine . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
}
|
|
|
|
|
2006-12-25 06:39:02 +00:00
|
|
|
if ($this->_debug){
|
|
|
|
$this->delivery = 'debug';
|
|
|
|
}
|
2006-09-12 00:26:50 +00:00
|
|
|
$__method = '__'.$this->delivery;
|
2007-03-27 02:59:22 +00:00
|
|
|
|
2006-12-25 06:39:02 +00:00
|
|
|
return $this->$__method();
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-09-23 23:35:22 +00:00
|
|
|
function reset() {
|
|
|
|
$this->to = null;
|
|
|
|
$this->from = null;
|
|
|
|
$this->replyTo = null;
|
|
|
|
$this->return = null;
|
|
|
|
$this->cc = array();
|
|
|
|
$this->bcc = array();
|
|
|
|
$this->subject = null;
|
2006-12-25 06:39:02 +00:00
|
|
|
$this->additionalParams = null;
|
2006-09-23 23:35:22 +00:00
|
|
|
$this->__header = null;
|
|
|
|
$this->__boundary = null;
|
|
|
|
$this->__message = null;
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $content
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
function __renderTemplate($content) {
|
|
|
|
$View = new View($this->Controller);
|
2007-04-03 01:15:24 +00:00
|
|
|
$View->layout = $this->layout;
|
2006-12-25 06:39:02 +00:00
|
|
|
if($this->sendAs === 'both'){
|
2007-03-25 18:16:24 +00:00
|
|
|
$htmlContent = $content;
|
2006-12-25 06:39:02 +00:00
|
|
|
$msg = '--' . $this->__boundary . $this->_newLine;
|
|
|
|
$msg .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
$msg .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
2007-02-02 02:47:53 +00:00
|
|
|
$content = $View->renderElement('email' . DS . 'text' . DS . $this->template, array('content' => $content), true);
|
2007-02-01 20:11:28 +00:00
|
|
|
$View->layoutPath = 'email' . DS . 'text';
|
|
|
|
$msg .= $View->renderLayout($content) . $this->_newLine;
|
|
|
|
|
2007-03-08 02:01:29 +00:00
|
|
|
$msg .= $this->_newLine. '--' . $this->__boundary . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
$msg .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
|
2006-12-25 06:39:02 +00:00
|
|
|
$msg .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
2007-03-25 18:16:24 +00:00
|
|
|
$content = $View->renderElement('email' . DS . 'html' . DS . $this->template, array('content' => $htmlContent), true);
|
2006-12-25 06:39:02 +00:00
|
|
|
$View->layoutPath = 'email' . DS . 'html';
|
|
|
|
$msg .= $View->renderLayout($content);
|
|
|
|
|
|
|
|
return $msg;
|
|
|
|
} else {
|
2007-02-02 02:47:53 +00:00
|
|
|
$content = $View->renderElement('email' . DS . $this->sendAs . DS . $this->template, array('content' => $content), true);
|
2006-12-25 06:39:02 +00:00
|
|
|
$View->layoutPath = 'email' . DS . $this->sendAs;
|
|
|
|
return $View->renderLayout($content);
|
|
|
|
}
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __createBoundary(){
|
|
|
|
$this->__boundary = md5(uniqid(time()));
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __createHeader(){
|
2007-03-28 22:57:07 +00:00
|
|
|
$this->__header .= 'From: ' . $this->__formatAddress($this->from) . $this->_newLine;
|
|
|
|
$this->__header .= 'Reply-To: ' . $this->__formatAddress($this->replyTo) . $this->_newLine;
|
|
|
|
$this->__header .= 'Return-Path: ' . $this->__formatAddress($this->return) . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
|
|
|
|
$addresses = null;
|
|
|
|
if(!empty($this->cc)) {
|
|
|
|
foreach ($this->cc as $cc) {
|
2007-03-28 22:57:07 +00:00
|
|
|
$addresses .= $this->__formatAddress($cc) . ', ';
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
$this->__header .= 'cc: ' . $addresses . $this->_newLine;
|
2006-12-25 06:39:02 +00:00
|
|
|
//$this->to .= ', ' . $addresses;
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
2007-04-04 07:46:04 +00:00
|
|
|
$addresses = null;
|
2006-09-12 00:26:50 +00:00
|
|
|
if(!empty($this->bcc)) {
|
|
|
|
foreach ($this->bcc as $bcc) {
|
2007-03-28 22:57:07 +00:00
|
|
|
$addresses .= $this->__formatAddress($bcc) . ', ';
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
$this->__header .= 'Bcc: ' . $addresses . $this->_newLine;
|
2006-12-25 06:39:02 +00:00
|
|
|
//$this->to .= ', ' . $addresses;
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->__header .= 'X-Mailer: ' . $this->xMailer . $this->_newLine;
|
|
|
|
|
2006-09-21 08:49:18 +00:00
|
|
|
if(!empty($this->attachments) && $this->sendAs === 'text') {
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__createBoundary();
|
2006-09-12 00:26:50 +00:00
|
|
|
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__header .= 'Content-Type: multipart/mixed; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
2006-09-21 08:49:18 +00:00
|
|
|
} elseif(!empty($this->attachments) && $this->sendAs === 'html') {
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__createBoundary();
|
2006-09-12 00:26:50 +00:00
|
|
|
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__header .= 'Content-Type: multipart/related; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
} elseif($this->sendAs === 'html') {
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__header .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
|
|
|
|
$this->__header .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
|
|
|
} elseif($this->sendAs === 'both') {
|
|
|
|
$this->__createBoundary();
|
2006-09-12 00:26:50 +00:00
|
|
|
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
2007-02-01 20:11:28 +00:00
|
|
|
$this->__header .= 'Content-Type: multipart/alternative; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __formatMessage($message){
|
2006-09-12 01:55:32 +00:00
|
|
|
$message = $this->__wrap($message);
|
2006-09-12 00:26:50 +00:00
|
|
|
|
2006-12-25 06:39:02 +00:00
|
|
|
if($this->sendAs === 'both'){
|
2006-09-21 08:49:18 +00:00
|
|
|
$this->__message = '--' . $this->__boundary . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
|
|
|
$this->__message .= 'If you are seeing this is because you may need to change your'.$this->_newLine;
|
|
|
|
$this->__message .= 'preferred message format from HTML to plain text.'.$this->_newLine.$this->_newLine;
|
2006-09-12 01:55:32 +00:00
|
|
|
$this->__message .= strip_tags($message) . $this->_newLine;
|
2006-09-21 08:49:18 +00:00
|
|
|
|
2006-12-25 06:39:02 +00:00
|
|
|
$this->__message .= '--' . $this->__boundary . $this->_newLine;
|
2006-09-12 01:55:32 +00:00
|
|
|
$this->__message .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
|
|
|
$this->__message .= $message . $this->_newLine;
|
|
|
|
$this->__message .= $this->_newLine . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
} else {
|
2006-09-12 01:55:32 +00:00
|
|
|
$this->__message .= $message . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __attachFiles(){
|
|
|
|
foreach($this->attachments as $attachment) {
|
|
|
|
$files[] = $this->__findFiles($attachment);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($files as $file) {
|
|
|
|
$handle = fopen($file, 'rb');
|
|
|
|
$data = fread($handle, filesize($file));
|
|
|
|
$data = chunk_split(base64_encode($data)) ;
|
|
|
|
$filetype = mime_content_type($file);
|
|
|
|
|
2006-09-12 01:55:32 +00:00
|
|
|
$this->__message .= '--' . $this->__boundary . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Type: ' . $filetype . '; name="' . $file . '"' . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Transfer-Encoding: base64' . $this->_newLine;
|
|
|
|
$this->__message .= 'Content-Disposition: attachment; filename="' .$file. '"' . $this->_newLine . $this->_newLine;
|
|
|
|
$this->__message .= $data . $this->_newLine . $this->_newLine;
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $attachment
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __findFiles($attachment){
|
|
|
|
foreach($this->filePaths as $path) {
|
|
|
|
if (file_exists($path . DS . $attachment)) {
|
|
|
|
$file = $path . DS . $attachment;
|
|
|
|
return $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 01:55:32 +00:00
|
|
|
function __wrap($message) {
|
2006-09-21 09:32:05 +00:00
|
|
|
$message = str_replace(array('\r','\n'), '\n', $message);
|
|
|
|
$words = explode('\n', $message);
|
2006-09-21 08:49:18 +00:00
|
|
|
$formated = null;
|
2006-09-12 01:55:32 +00:00
|
|
|
foreach ($words as $word) {
|
2006-09-21 09:32:05 +00:00
|
|
|
$formated .= wordwrap($word, $this->_lineLength, ' ', 1);
|
|
|
|
$formated .= "\n";
|
2006-09-12 01:55:32 +00:00
|
|
|
}
|
|
|
|
return $formated;
|
|
|
|
}
|
2007-03-28 22:57:07 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $subject
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
|
|
|
function __encode($subject) {
|
|
|
|
if(low($this->charset) !== 'iso-8859-15') {
|
|
|
|
$start = "=?" . $this->charset . "?B?";
|
|
|
|
$end = "?=";
|
|
|
|
$spacer = $end . "\n " . $start;
|
|
|
|
|
|
|
|
$length = 75 - strlen($start) - strlen($end);
|
|
|
|
$length = $length - ($length % 4);
|
|
|
|
|
|
|
|
$subject = base64_encode($subject);
|
|
|
|
$subject = chunk_split($subject, $length, $spacer);
|
|
|
|
$spacer = preg_quote($spacer);
|
|
|
|
$subject = preg_replace("/" . $spacer . "$/", "", $subject);
|
|
|
|
$subject = $start . $subject . $end;
|
|
|
|
}
|
2007-04-03 01:15:24 +00:00
|
|
|
|
2007-03-28 22:57:07 +00:00
|
|
|
return $subject;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param string $string
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
|
|
|
function __formatAddress($string){
|
|
|
|
if(strpos($string, '<') !== false){
|
|
|
|
$value = explode('<', $string);
|
|
|
|
$string = $this->__encode($value[0]) . ' <' . $value[1];
|
|
|
|
}
|
2007-04-03 01:08:49 +00:00
|
|
|
return $string;
|
2007-03-28 22:57:07 +00:00
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 00:26:50 +00:00
|
|
|
function __mail(){
|
2006-12-25 06:39:02 +00:00
|
|
|
return @mail($this->to, $this->subject, $this->__message, $this->__header, $this->additionalParams);
|
2006-09-12 01:55:32 +00:00
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-09-12 01:55:32 +00:00
|
|
|
function __smtp(){
|
|
|
|
|
2006-09-12 00:26:50 +00:00
|
|
|
}
|
2006-12-25 10:51:08 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-12-25 06:39:02 +00:00
|
|
|
function __debug() {
|
|
|
|
$fm = '<pre>';
|
|
|
|
$fm .= sprintf('%s %s', 'To:', $this->to);
|
|
|
|
$fm .= sprintf('%s %s', 'Subject:', $this->subject);
|
|
|
|
$fm .= sprintf('%s\n\n%s', 'Header:', $this->__header);
|
|
|
|
$fm .= sprintf('%s\n\n%s', 'Parameters:', $this->additionalParams);
|
|
|
|
$fm .= sprintf('%s\n\n%s', 'Message:', $this->__message);
|
|
|
|
$fm .= '</pre>';
|
|
|
|
|
|
|
|
$this->Controller->Session->setFlash($fm, 'default', null, 'email');
|
|
|
|
return true;
|
|
|
|
}
|
2006-09-11 20:06:01 +00:00
|
|
|
}
|
2006-12-25 06:39:02 +00:00
|
|
|
?>
|