Adding patch from #1851.

Fixed #1851 and #1876

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4391 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-02-01 20:11:28 +00:00
parent 67e582cc2f
commit e4a9ab6959

View file

@ -162,7 +162,7 @@ class EmailComponent extends Object{
* @var string
* @access protected
*/
var $_newLine = "\r\n";
var $_newLine = "\n";
/**
* Enter description here...
*
@ -208,7 +208,6 @@ class EmailComponent extends Object{
* @access public
*/
function send($content = null){
$this->__createBoundary();
$this->__createHeader();
if($this->template === null) {
@ -229,6 +228,10 @@ class EmailComponent extends Object{
$this->__attachFiles();
}
if (!is_null($this->__boundary)) {
$this->__message .= '--' . $this->__boundary . '--' . $this->_newLine . $this->_newLine;
}
if ($this->_debug){
$this->delivery = 'debug';
}
@ -265,17 +268,18 @@ class EmailComponent extends Object{
if($this->sendAs === 'both'){
$msg = '--' . $this->__boundary . $this->_newLine;
$msg .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
$msg .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
$content = $View->renderElement('email' . DS . 'text' . DS . $this->template, array('content' => $content));
$View->layoutPath = 'email' . DS . 'text';
$msg .= $View->renderLayout($content) . $this->_newLine;
$msg .= '--' . $this->__boundary . $this->_newLine;
$msg .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
$msg .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
$content = $View->renderElement('email' . DS . 'html' . DS . $this->template, array('content' => $content));
$View->layoutPath = 'email' . DS . 'html';
$msg .= $View->renderLayout($content);
$msg .= '--' . $this->__boundary . $this->_newLine;
$msg .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
$msg .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
$content = $View->renderElement('email' . DS . 'text' . DS . $this->template, array('content' => $content));
$View->layoutPath = 'email' . DS . 'text';
$msg .= $View->renderLayout($content);
return $msg;
} else {
$content = $View->renderElement('email' . DS . $this->sendAs . DS . $this->template, array('content' => $content));
@ -320,14 +324,20 @@ class EmailComponent extends Object{
$this->__header .= 'X-Mailer: ' . $this->xMailer . $this->_newLine;
if(!empty($this->attachments) && $this->sendAs === 'text') {
$this->__createBoundary();
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
$this->__header .= 'Content-Type: multipart/mixed; boundary=' . $this->__boundary . $this->_newLine;
$this->__header .= 'Content-Type: multipart/mixed; boundary="' . $this->__boundary . '"' . $this->_newLine;
} elseif(!empty($this->attachments) && $this->sendAs === 'html') {
$this->__createBoundary();
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
$this->__header .= 'Content-Type: multipart/related; boundary=' . $this->__boundary . $this->_newLine;
$this->__header .= 'Content-Type: multipart/related; boundary="' . $this->__boundary . '"' . $this->_newLine;
} elseif($this->sendAs === 'html') {
$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();
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
$this->__header .= 'Content-Type: multipart/alternative; boundary=' . $this->__boundary . $this->_newLine;
$this->__header .= 'Content-Type: multipart/alternative; boundary="' . $this->__boundary . '"' . $this->_newLine;
}
}
/**