function getBody()
{
if ($this->parts && $this->body === null) {
foreach ($this->parts as $part) {
$partNo = $part['partNo'];
$encoding = $part['encoding'];
$charset = $part['charset'];
$body = imap_fetchbody($this->message->getMailbox(), $this->message->getUID(), $partNo, FT_UID);
$body = BrIMAP::decode($body, $encoding);
if ($charset) {
$body = @iconv($charset, 'UTF-8', $body);
}
$body = trim($body);
$body = preg_replace('~<head[^>]*?>.*?</head>~ism', '', $body);
$body = preg_replace('~<meta[^>]*?>~ism', '', $body);
$body = preg_replace('~<base[^>]*?>~ism', '', $body);
$body = preg_replace('~<style[^>]*?>.*?</style>~ism', '', $body);
if ($this->isHTML && $body) {
try {
$doc = phpQuery::newDocument($body);
$bodyTag = $doc->find('body');
if ($bodyTag->length() > 0) {
$body = trim(pq($bodyTag)->html());
} else {
$body = trim($doc->html());
}
phpQuery::unloadDocuments();
} catch (Exception $e) {
}
}
$this->body .= $body;
}
}
return $this->body;
}