- $body .= formatBody($imapConnection, $message, $color, $wrap_at, $trans_ar[$i], $passed_id, $mailbox, true);
+ /* reduced version of formatBody and translateText functions */
+
+ // get message entity information
+ $body_message = getEntity($message, $trans_ar[$i]);
+ // get message body
+ $body = mime_fetch_body ($imapConnection, $passed_id, $trans_ar[$i]);
+ // convert encoded messages
+ $body = decodeBody($body, $body_message->header->encoding);
+
+ /*
+ * if message part is html formated - convert spaces, html line feeds,
+ * less than and greater than html entities and remove tags
+ */
+ if ($body_message->header->type1 == 'html') {
+ $entity_conv = array(' ' => ' ',
+ '<p>' => "\n",
+ '<P>' => "\n",
+ '<br>' => "\n",
+ '<BR>' => "\n",
+ '<br />' => "\n",
+ '<BR />' => "\n",
+ '>' => '>',
+ '<' => '<');
+ $body = strtr($body, $entity_conv);
+ $body = strip_tags($body);
+ }
+ // remove whitespace
+ $body = trim($body);
+ // save processed text and parse other entity
+ $final_body.= charset_decode($body_message->header->getParameter('charset'),$body);