diff --git a/include/class.mailer.php b/include/class.mailer.php index 889ecb39fdc60b767633bc3ded23de6a1e3ee203..e13eff86e450589c82253468e14864d0b97d4c1b 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -136,12 +136,23 @@ class Mailer { $mime = new Mail_mime(); - // Make sure nothing unsafe has creeped into the message - $message = Format::safe_html($message); - $mime->setTXTBody(convert_html_to_text($message)); + $isHtml = true; + // Ensure that the 'text' option / hint is not set to true and that + // the message appears to be HTML -- that is, the first + // non-whitespace char is a '<' character + if (!(isset($options['text']) && $options['text']) + && preg_match('/^\s*</', $message)) { + // Make sure nothing unsafe has creeped into the message + $message = Format::safe_html($message); + $mime->setTXTBody(convert_html_to_text($message)); + } + else { + $mime->setTXTBody($message); + $isHtml = false; + } $domain = 'local'; - if ($ost->getConfig()->isHtmlThreadEnabled()) { + if ($isHtml && $ost->getConfig()->isHtmlThreadEnabled()) { // TODO: Lookup helpdesk domain $domain = substr(md5($ost->getConfig()->getURL()), -12); // Format content-ids with the domain, and add the inline images diff --git a/include/class.osticket.php b/include/class.osticket.php index a2d2205de0adedfcff9e722efe5745485cda00fc..fd46d21346928ca443ed56f1842e15e9a35bb27e 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -232,7 +232,7 @@ class osTicket { $email=$this->getConfig()->getDefaultEmail(); //will take the default email. if($email) { - $email->sendAlert($to, $subject, $message); + $email->sendAlert($to, $subject, $message, null, array('text'=>true)); } else {//no luck - try the system mail. Mailer::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>',$to)); }