mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge changes from hmic/CakeEmail-2.0
Adds parameters for file attachments instead of having boundary prefixes in multiple places. Fixes #GH433
This commit is contained in:
parent
d4e2fbf6b8
commit
e6f5ebc257
1 changed files with 16 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue