Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIX: Fixed operation of inlined images in Mailer, when no inlined ima…

…ges actually attached.
  • Loading branch information...
commit 33a1fc7b3adeedb92f138321243deb3bffd66cc4 1 parent b7a1db7
@cbarberis cbarberis authored chillu committed
Showing with 8 additions and 7 deletions.
  1. +8 −7 email/Mailer.php
View
15 email/Mailer.php
@@ -291,7 +291,7 @@ function encodeMultipart($parts, $contentType, $headers = false) {
*/
function wrapImagesInline($htmlContent) {
global $_INLINED_IMAGES;
- $_INLINED_IMAGES = null;
+ $_INLINED_IMAGES = array();
$replacedContent = imageRewriter($htmlContent, 'wrapImagesInline_rewriter($URL)');
@@ -303,8 +303,8 @@ function wrapImagesInline($htmlContent) {
// Make all the image parts
global $_INLINED_IMAGES;
- foreach($_INLINED_IMAGES as $url => $cid) {
- $multiparts[] = encodeFileForEmail($url, false, "inline", "Content-ID: <$cid>\n");
+ if($_INLINED_IMAGES) foreach($_INLINED_IMAGES as $url => $cid) {
+ $multiparts[] = encodeFileForEmail(BASE_PATH . '/' . $url, false, "inline", "Content-ID: <$cid>\n");
}
// Merge together in a multipart
@@ -312,10 +312,10 @@ function wrapImagesInline($htmlContent) {
return processHeaders($headers, $body);
}
function wrapImagesInline_rewriter($url) {
- $url = relativiseURL($url);
+ $url = Director::makeRelative($url);
global $_INLINED_IMAGES;
- if(!$_INLINED_IMAGES[$url]) {
+ if(!isset($_INLINED_IMAGES[$url])) {
$identifier = "automatedmessage." . rand(1000,1000000000) . "@silverstripe.com";
$_INLINED_IMAGES[$url] = $identifier;
}
@@ -384,6 +384,7 @@ function encodeFileForEmail($file, $destFileName = false, $disposition = NULL, $
$file = array('filename' => $file);
$fh = fopen($file['filename'], "rb");
if ($fh) {
+ $file['contents'] = "";
while(!feof($fh)) $file['contents'] .= fread($fh, 10000);
fclose($fh);
}
@@ -393,12 +394,12 @@ function encodeFileForEmail($file, $destFileName = false, $disposition = NULL, $
if(!$destFileName) $base = basename($file['filename']);
else $base = $destFileName;
- $mimeType = $file['mimetype'] ? $file['mimetype'] : HTTP::get_mime_type($file['filename']);
+ $mimeType = !empty($file['mimetype']) ? $file['mimetype'] : HTTP::get_mime_type($file['filename']);
if(!$mimeType) $mimeType = "application/unknown";
if (empty($disposition)) $disposition = isset($file['contentLocation']) ? 'inline' : 'attachment';
// Encode for emailing
- if (substr($file['mimetype'], 0, 4) != 'text') {
+ if (substr($mimeType, 0, 4) != 'text') {
$encoding = "base64";
$file['contents'] = chunk_split(base64_encode($file['contents']));
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.