Index: branches/5.2.x/core/kernel/utility/email.php =================================================================== diff -u -N -r15363 -r15383 --- branches/5.2.x/core/kernel/utility/email.php (.../email.php) (revision 15363) +++ branches/5.2.x/core/kernel/utility/email.php (.../email.php) (revision 15383) @@ -1,6 +1,6 @@ GetDBField($is_html ? 'HtmlEmailTemplate' : 'TextEmailTemplate'); if ( !$is_html && !$design_template ) { - $design_template = $this->sender->ConvertToText($language->GetDBField('HtmlEmailTemplate')); + $design_template = $this->sender->ConvertToText($language->GetDBField('HtmlEmailTemplate'), true); } $design_templates[$design_key] = $design_template; @@ -754,15 +753,14 @@ * @param bool $is_html * @return bool|string * @access protected - * @todo maybe ConvertToText will strip all emailEvent->GetField($is_html ? 'HtmlBody' : 'PlainTextBody'); if ( !trim($message_body) && !$is_html ) { // no plain text part available -> make it from html part then - $message_body = $this->sender->ConvertToText($this->emailEvent->GetField('HtmlBody')); + $message_body = $this->sender->ConvertToText($this->emailEvent->GetField('HtmlBody'), true); } if ( !trim($message_body) ) { Index: branches/5.2.x/core/kernel/utility/email_send.php =================================================================== diff -u -N -r15137 -r15383 --- branches/5.2.x/core/kernel/utility/email_send.php (.../email_send.php) (revision 15137) +++ branches/5.2.x/core/kernel/utility/email_send.php (.../email_send.php) (revision 15383) @@ -1,6 +1,6 @@ ]*?)([\\/]?>)/s', $html, $regs) ) { + $found_tags = Array (); + + foreach ($regs[0] as $index => $tag) { + $tag_placeholder = '%' . md5($index . ':' . $tag) . '%'; + $found_tags[$tag_placeholder] = $tag; + + // we can have duplicate tags -> replace only 1st occurrence (str_replace can't do that) + $html = preg_replace('/' . preg_quote($tag, '/') . '/', $tag_placeholder, $html, 1); + } + + $html = $this->_convertToText($html); + + foreach ($found_tags as $tag_placeholder => $tag) { + $html = str_replace($tag_placeholder, $tag, $html); + } + + return $html; + } + + return $this->_convertToText($html); + } + + /** + * Returns text version of HTML document + * + * @param string $html + * @return string + */ + protected function _convertToText($html) + { $search = Array ( "'(<\/td>.*)[\r\n]+(.*[\r\n]{0,2})|(<\/p>)|(<\/div>)|(<\/tr>)'i",