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