1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Fixed - mail handler now embedding images with the {THEME} constant correctly.

This commit is contained in:
Cameron 2014-08-18 23:16:10 -07:00
parent ceb0fff60d
commit 9acc933dea
2 changed files with 53 additions and 6 deletions

View File

@ -191,12 +191,11 @@ $MAILOUT_FOOTER = "
*/
// FIXME clean up the whole email template/render tempalte mess
//-------------------------------------------------------------
// 'SIGNUP' TEMPLATE
//-------------------------------------------------------------
//@Deprecated
$SIGNUPEMAIL_TEMPLATE = "
<div style='padding:10px'>
<div style='text-align:left; width:90%'>
@ -357,6 +356,8 @@ $EMAIL_TEMPLATE['default']['footer'] = "<br /><br />
</body>
</html>";
// -------------------------------
/**
* Signup Template.
@ -392,7 +393,7 @@ $EMAIL_TEMPLATE['signup']['body'] = "
{SITENAME=link}<br />
{SITEURL}
<br /><br />".($includeSiteButton ? "<a href='".SITEURL."' title=''><img src='".e_IMAGE_ABS.str_replace('{e_IMAGE}', '', $includeSiteButton)."' alt='' /></a>" : '')."
<br /><br />".($includeSiteButton ? "<a href='".SITEURL."' title=''>{SITEBUTTON}</a>" : '')."
</div>
";
@ -402,6 +403,11 @@ $EMAIL_TEMPLATE['signup']['footer'] = "</div>
$EMAIL_TEMPLATE['signup']['cc'] = "";
$EMAIL_TEMPLATE['signup']['bcc'] = "";
$EMAIL_TEMPLATE['signup']['attachments'] = "";
//TODO FIXME {SITEBUTTON} not working at the moment. (broken path)
// -----------------------------
/*
* QUICK ADD USER EMAIL TEMPLATE - BODY.
@ -415,6 +421,9 @@ $EMAIL_TEMPLATE['quickadduser']['header'] = $EMAIL_TEMPLATE['default']['header'
$EMAIL_TEMPLATE['quickadduser']['body'] = USRLAN_185.USRLAN_186;
$EMAIL_TEMPLATE['quickadduser']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default footer above.
// ---------------------------------
// Notify (@see admin-> notify) // TODO
$EMAIL_TEMPLATE['notify']['subject'] = '{SITENAME}: {SUBJECT} ';
@ -422,4 +431,15 @@ $EMAIL_TEMPLATE['notify']['header'] = $EMAIL_TEMPLATE['default']['header']; /
$EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above.
$EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above.
// A Dummy Example for theme developers.
$EMAIL_TEMPLATE['example']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['example']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['example']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above.
$EMAIL_TEMPLATE['example']['footer'] = "<br /><br />
<a href='{SITEURL}'><img src='{THEME}images/my-signature.png' alt='{SITENAME}' /></a>
</div>
</body>
</html>";
?>

View File

@ -825,20 +825,28 @@ class e107Email extends PHPMailer
*/
public function MsgHTML($message, $basedir = '')
{
preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well
if(isset($images[3]))
{
if($this->debug)
{
echo "<h4>Detected Image Paths</h4>";
print_a($images[3]);
}
$tp = e107::getParser();
foreach($images[3] as $i => $url)
{
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url))
{
$url = $tp->replaceConstants($url);
$delim = $images[2][$i]; // Will be single or double quote
$filename = basename($url);
$directory = dirname($url);
@ -848,7 +856,12 @@ class e107Email extends PHPMailer
$directory = substr(SERVERBASE, 0, -1).$directory; // Convert to absolute server reference
$basedir = '';
}
//echo "CID file {$filename} in {$directory}. Base = ".SERVERBASE."< BaseDir = {$basedir}<br />";
if ($this->debug)
{
echo "<br />CID file {$filename} in {$directory}. Base = ".SERVERBASE."< BaseDir = {$basedir}<br />";
}
$cid = 'cid:' . md5($filename);
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = self::_mime_types($ext);
@ -858,15 +871,29 @@ class e107Email extends PHPMailer
if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) )
{
// $images[1][$i] contains 'src' or 'background'
$message = preg_replace("/".$images[1][$i]."=".$delim.preg_quote($url, '/').$delim."/Ui", $images[1][$i]."=".$delim.$cid.$delim, $message);
$message = preg_replace("/".$images[1][$i]."=".$delim.preg_quote($images[3][$i], '/').$delim."/Ui", $images[1][$i]."=".$delim.$cid.$delim, $message);
}
else
{
if ($this->debug) echo "Add embedded image {$url} failed<br />";
if ($this->debug)
{
echo "Add embedded image {$url} failed<br />";
echo "<br />basedir=".$basedir;
echo "<br />dir=".$directory;
echo "<br />file=".$filename;
echo "<br />";
}
}
}
elseif($this->debug)
{
echo "<br />Absolute Image: ".$url;
}
}
}
$this->IsHTML(true);
$this->Body = $message;
//print_a($message);