|
@@ -190,6 +190,10 @@ class EmailLib extends CakeEmail {
|
|
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
|
|
$mimeType = $this->_getMimeByExtension($ext);
|
|
$mimeType = $this->_getMimeByExtension($ext);
|
|
|
}
|
|
}
|
|
|
|
|
+ if ($contentId === null && ($cid = $this->_isEmbeddedBlobAttachment($content, $filename))) {
|
|
|
|
|
+ return $cid;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$options['content'] = $content;
|
|
$options['content'] = $content;
|
|
|
$options['mimetype'] = $mimeType;
|
|
$options['mimetype'] = $mimeType;
|
|
|
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', CakeText::uuid()) . '@' . $this->_domain;
|
|
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', CakeText::uuid()) . '@' . $this->_domain;
|
|
@@ -221,6 +225,25 @@ class EmailLib extends CakeEmail {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Returns if this particular file has already been attached as embedded file with this exact name
|
|
|
|
|
+ * to prevent the same image to overwrite each other and also to only send this image once.
|
|
|
|
|
+ * Allows multiple usage of the same embedded image (using the same cid)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return string cid of the found file or false if no such attachment can be found
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function _isEmbeddedBlobAttachment($content, $name) {
|
|
|
|
|
+ foreach ($this->_attachments as $filename => $fileInfo) {
|
|
|
|
|
+ if ($filename !== $name) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($fileInfo['content'] === $content) {
|
|
|
|
|
+ return $fileInfo['contentId'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Try to determine the mimetype by filename.
|
|
* Try to determine the mimetype by filename.
|
|
|
* Uses finfo_open() if availble, otherwise guesses it via file extension.
|
|
* Uses finfo_open() if availble, otherwise guesses it via file extension.
|
|
|
*
|
|
*
|