diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index bc36301cb..bc5b821a7 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1240,9 +1240,14 @@ class CakeEmail { /** * Attach non-embedded files by adding file contents inside boundaries. * + * @param string $boundary Boundary to use. If null, will default to $this->_boundary * @return array An array of lines to add to the message */ - protected function _attachFiles() { + protected function _attachFiles($boundary = null) { + if ($boundary === null) { + $boundary = $this->_boundary; + } + $msg = array(); foreach ($this->_attachments as $filename => $fileInfo) { if (!empty($fileInfo['contentId'])) { @@ -1250,7 +1255,7 @@ class CakeEmail { } $data = $this->_readFile($fileInfo['file']); - $msg[] = '--' . $this->_boundary; + $msg[] = '--' . $boundary; $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; $msg[] = 'Content-Transfer-Encoding: base64'; $msg[] = 'Content-Disposition: attachment; filename="' . $filename . '"'; @@ -1278,9 +1283,14 @@ class CakeEmail { /** * Attach inline/embedded files to the message. * + * @param string $boundary Boundary to use. If null, will default to $this->_boundary * @return array An array of lines to add to the message */ - protected function _attachInlineFiles() { + protected function _attachInlineFiles($boundary = null) { + if ($boundary === null) { + $boundary = $this->_boundary; + } + $msg = array(); foreach ($this->_attachments as $filename => $fileInfo) { if (empty($fileInfo['contentId'])) { @@ -1288,7 +1298,7 @@ class CakeEmail { } $data = $this->_readFile($fileInfo['file']); - $msg[] = '--rel-' . $this->_boundary; + $msg[] = '--' . $boundary; $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; $msg[] = 'Content-Transfer-Encoding: base64'; $msg[] = 'Content-ID: <' . $fileInfo['contentId'] . '>'; @@ -1365,7 +1375,7 @@ class CakeEmail { } if ($hasInlineAttachments) { - $attachments = $this->_attachInlineFiles(); + $attachments = $this->_attachInlineFiles($relBoundary); $msg = array_merge($msg, $attachments); $msg[] = ''; $msg[] = '--' . $relBoundary . '--'; @@ -1373,7 +1383,7 @@ class CakeEmail { } if ($hasAttachments) { - $attachments = $this->_attachFiles(); + $attachments = $this->_attachFiles($boundary); $msg = array_merge($msg, $attachments); } if ($hasAttachments || $hasMultipleTypes) {