mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Re-added wrapImagesInline and wrapImagesInline_rewriter to Mailer class
Deprecated in fb076c03, but can't be removed just yet. Also included some fixes which have since been applied in 3.0 to this.
This commit is contained in:
parent
634c91c6ff
commit
7327f120aa
@ -398,6 +398,45 @@ function validEmailAddr($emailAddress) {
|
||||
|
||||
return $emailAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a multipart/related e-mail chunk for the given HTML message and its linked images
|
||||
* Decodes absolute URLs, accessing the appropriate local images
|
||||
*/
|
||||
function wrapImagesInline($htmlContent) {
|
||||
global $_INLINED_IMAGES;
|
||||
$_INLINED_IMAGES = null;
|
||||
|
||||
$replacedContent = imageRewriter($htmlContent, 'wrapImagesInline_rewriter($URL)');
|
||||
|
||||
|
||||
// Make the HTML part
|
||||
$headers["Content-Type"] = "text/html; charset=utf-8";
|
||||
$headers["Content-Transfer-Encoding"] = "quoted-printable";
|
||||
$multiparts[] = processHeaders($headers, QuotedPrintable_encode($replacedContent));
|
||||
|
||||
// Make all the image parts
|
||||
global $_INLINED_IMAGES;
|
||||
foreach($_INLINED_IMAGES as $url => $cid) {
|
||||
$multiparts[] = encodeFileForEmail($url, false, "inline", "Content-ID: <$cid>\n");
|
||||
}
|
||||
|
||||
// Merge together in a multipart
|
||||
list($body, $headers) = encodeMultipart($multiparts, "multipart/related");
|
||||
return processHeaders($headers, $body);
|
||||
}
|
||||
|
||||
function wrapImagesInline_rewriter($url) {
|
||||
$url = relativiseURL($url);
|
||||
|
||||
global $_INLINED_IMAGES;
|
||||
if(!$_INLINED_IMAGES[$url]) {
|
||||
$identifier = "automatedmessage." . rand(1000,1000000000) . "@silverstripe.com";
|
||||
$_INLINED_IMAGES[$url] = $identifier;
|
||||
}
|
||||
return "cid:" . $_INLINED_IMAGES[$url];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user