From e4a9ab69598cfe628593cb6cd03a7761d4984071 Mon Sep 17 00:00:00 2001 From: phpnut Date: Thu, 1 Feb 2007 20:11:28 +0000 Subject: [PATCH] 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 --- cake/libs/controller/components/email.php | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index a3725c253..135383ae4 100644 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -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; } } /**