Index: kernel/utility/email.php =================================================================== --- kernel/utility/email.php (revision 15363) +++ kernel/utility/email.php (working copy) @@ -724,7 +724,6 @@ * @param bool $is_html * @return string * @access protected - * @todo maybe ConvertToText will strip all 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,7 +753,6 @@ * @param bool $is_html * @return bool|string * @access protected - * @todo maybe ConvertToText will strip all 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: kernel/utility/email_send.php =================================================================== --- kernel/utility/email_send.php (revision 15359) +++ kernel/utility/email_send.php (working copy) @@ -615,10 +615,42 @@ * Returns text version of HTML document * * @param string $html + * @param bool $keep_inp_tags * @return string */ - function ConvertToText($html) + function ConvertToText($html, $keep_inp_tags = false) { + if ( $keep_inp_tags && preg_match_all('/(<[\\/]?)inp2:([^>]*?)([\\/]?>)/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",