if ($format[1] == 'plain') {
return $this->body;
}
- $res = preg_replace("@<br[^>]>@", "@@@#@", $this->body);
- $res = trim(html_entity_decode(strip_tags($res)));
- $res = str_replace("@@@#@", "\n", $res);
- if (!is_utf8($res)) {
- $res = utf8_encode($res);
+ if ($format[1] == 'richtext') {
+ return htmlToPlainText(richtextToHtml($this->body));
+ } else {
+ return htmlToPlainText($this->body);
}
- return $res;
}
/** decode an attachment
preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
$format = $format[1];
- $res .= '<tr><td colspan="2">';
+ $res .= '<tr><td colspan="2"';
if ($format == 'html') {
- $res .= formatbody($this->body, $format);
+ if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {
+ $res .= ' bgcolor="'.$bgcolor[1].'"';
+ }
+ $res .= '>'.formatbody($this->body, $format);
} else {
- $res .= '<pre>'.formatbody($this->body).'</pre>';
+ $res .= '><pre>'.formatbody($this->body).'</pre>';
}
$res .= '</td></tr>';