From 5a2ce38e086b3b5b9c946acef8c0fec152b1d12c Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 18 Oct 2014 05:18:51 -0700 Subject: [PATCH] Fix for images in mail preview. --- e107_admin/mailout.php | 14 ++++++++------ e107_handlers/mail.php | 9 +++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index c20183914..01bbc9421 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -591,13 +591,14 @@ class mailout_main_ui extends e_admin_ui function previewPage() { $mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($_GET['id'])." LIMIT 1"); - - + $data = $this->mailAdmin->dbToMail($mailData); - + $eml = array( - 'body' => $data['mail_body'], - 'template' => $data['mail_send_style'] + 'subject' => $data['mail_subject'], + 'body' => $data['mail_body'], + 'template' => $data['mail_send_style'], + 'shortcodes' => array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567") ); return e107::getEmail()->preview($eml); @@ -1284,9 +1285,10 @@ class mailout_admin_form_ui extends e_admin_form_ui { $text = ""; - $link = e_SELF."?mode=main&action=send&id=".$id; + $preview = e_SELF."?mode=main&action=preview&id=".$id; $text .= "".E_32_MAIL.""; + $text .= "".E_32_SEARCH.""; $text .= $this->renderValue('options',$value,$att,$id); return $text; diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 459661826..aab1b1b7c 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -156,7 +156,7 @@ class e107Email extends PHPMailer public $legacyBody = false; // TRUE enables legacy conversion of plain text body to HTML in HTML emails private $debug = false; // echos various debug info when set to true. private $pref = array(); // Store code prefs. - + private $previewMode = false; /** * Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed * @@ -525,7 +525,10 @@ class e107Email extends PHPMailer $message = str_replace("\r","\n",$message); // Handle alternative newline characters $message = str_replace("\n", "
\n", $message); } + + $this->MsgHTML($message); // Theoretically this should do everything, including handling of inline images. + } else { // generate the plain text as the sole part of the email @@ -600,6 +603,8 @@ class e107Email extends PHPMailer */ public function preview($eml) { + $this->previewMode = true; + if (count($eml)) { if($error = $this->arraySet($eml)) // Set parameters from list @@ -888,7 +893,7 @@ class e107Email extends PHPMailer preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well - if(isset($images[3])) + if(isset($images[3]) && ($this->previewMode === false)) { if($this->debug)