This commit has been accessed 608 times via Git panel.
commit 3e7f70d0ffacde4a88e40cc981192ac899f22423
tree bdab3800b728268965ebb73693cd7f835724493f
parent 9152992e8ba5f9213e2a9c46b93db7cff3be730b
author Engels Antonio <engels@majcms.org> 1333690674 +0800
committer Engels Antonio <engels@majcms.org> 1333690674 +0800
Improve extraction of mail attachments
diff --git a/core.php b/core.php
index 1c570f8..791b31f 100644
--- a/core.php
+++ b/core.php
@@ -75,6 +75,9 @@ function HumanReadableFilesize($size) {
return round($size, 2) . ' ' . $units[$i];
}
+
+// cleong@organic.com
+
function get_mime_type(&$struct) {
$primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
@@ -190,11 +193,141 @@ function is_image($path) {
$image_type = $a[2];
if (in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG , IMAGETYPE_BMP))) {
-
return true;
}
return false;
}
+
+// chris@isavvy.co.nz
+
+class EmailMessage {
+
+ protected $connection;
+ protected $messageNumber;
+
+ public $attachments;
+
+ public $getAttachments = true;
+
+ public function __construct($connection, $messageNumber) {
+
+ $this->connection = $connection;
+ $this->messageNumber = $messageNumber;
+ }
+
+ public function fetch() {
+
+ $structure = @imap_fetchstructure($this->connection, $this->messageNumber);
+
+ if (!$structure) {
+ return false;
+ }
+ else {
+ $this->recurse($structure->parts);
+ return true;
+ }
+
+ }
+
+ public function recurse($messageParts, $prefix = '', $index = 1, $fullPrefix = true) {
+
+ foreach ($messageParts as $part) {
+
+ $partNumber = $prefix . $index;
+
+ if ($part->type == 2) {
+
+ $msg = new EmailMessage($this->connection, $this->messageNumber);
+ $msg->getAttachments = $this->getAttachments;
+ $msg->recurse($part->parts, $partNumber.'.', 0, false);
+
+ $this->attachments[] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => '',
+ 'data' => $msg,
+ 'inline' => false,
+ );
+ }
+ elseif (isset($part->parts)) {
+
+ if ($fullPrefix) {
+ $this->recurse($part->parts, $prefix.$index.'.');
+ }
+ else {
+ $this->recurse($part->parts, $prefix);
+ }
+ }
+ elseif ($part->type > 2) {
+
+ if (isset($part->id)) {
+
+ $id = str_replace(array('<', '>'), '', $part->id);
+
+ $this->attachments[$id] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => $this->getFilenameFromPart($part),
+ 'data' => $this->getAttachments ? $this->getPart($partNumber, $part->encoding) : '',
+ 'inline' => true,
+ );
+ }
+ else {
+ $this->attachments[] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => $this->getFilenameFromPart($part),
+ 'data' => $this->getAttachments ? $this->getPart($partNumber, $part->encoding) : '',
+ 'inline' => false,
+ );
+ }
+ }
+ $index++;
+ }
+ }
+
+ function getPart($partNumber, $encoding) {
+
+ $data = imap_fetchbody($this->connection, $this->messageNumber, $partNumber);
+
+ switch($encoding) {
+
+ case 0: return $data; // 7BIT
+ case 1: return $data; // 8BIT
+ case 2: return $data; // BINARY
+ case 3: return base64_decode($data); // BASE64
+ case 4: return quoted_printable_decode($data); // QUOTED_PRINTABLE
+ case 5: return $data; // OTHER
+ }
+ }
+
+ function getFilenameFromPart($part) {
+
+ $filename = '';
+
+ if ($part->ifdparameters) {
+
+ foreach ($part->dparameters as $object) {
+
+ if (strtolower($object->attribute) == 'filename') {
+ $filename = $object->value;
+ }
+ }
+ }
+
+ if (!$filename && $part->ifparameters) {
+
+ foreach ($part->parameters as $object) {
+
+ if (strtolower($object->attribute) == 'name') {
+ $filename = $object->value;
+ }
+ }
+ }
+ return $filename;
+ }
+}
+
?>
diff --git a/folders.php b/folders.php
index d351752..f04cb1d 100644
--- a/folders.php
+++ b/folders.php
@@ -27,7 +27,6 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
- //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
echo "</form>";
}
@@ -49,7 +48,6 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
- //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
echo "</form>";
}
diff --git a/preload.php b/preload.php
index 9f1ae4f..8df500c 100644
--- a/preload.php
+++ b/preload.php
@@ -1,21 +1,9 @@
-<img src="images/ajax-loader.gif">
-<img src="images/attach.png">
-<img src="images/disable.png">
-<img src="images/enable.png">
-<img src="images/file.png">
-<img src="images/folder-close.png">
-<img src="images/folder-open.png">
-<img src="images/mail-forward.png">
-<img src="images/mail-new.png">
-<img src="images/mail-next.png">
-<img src="images/mail-prev.png">
-<img src="images/mail-read.png">
-<img src="images/mail-replied.png">
-<img src="images/mail-reply-all.png">
-<img src="images/mail-reply.png">
-<img src="images/mail-search.png">
-<img src="images/mail-settings.png">
-<img src="images/mail-unread.png">
-<img src="images/trashcan_empty.png">
-<img src="images/trashcan_full.png">
-<img src="images/trashcan_purge.png">
+<?php
+
+$preload_images = glob("images/{*.gif,*.jpg,*.png}",GLOB_BRACE);
+
+foreach ($preload_images as $preload_image) {
+ echo "<img src=\"$preload_image\">";
+}
+
+?>
diff --git a/read.php b/read.php
index 6b71992..2ba6b31 100644
--- a/read.php
+++ b/read.php
@@ -292,101 +292,58 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $struct = imap_fetchstructure($mbox, $msgno, FT_UID);
+ $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
+ $emailMessage->fetch();
- $contentParts = count($struct->parts);
+ if (count($emailMessage->attachments > 0)) {
- for ($n = 0; $n <= $contentParts; $n++) {
-
- $contentPart = imap_bodystruct($mbox,imap_msgno($mbox,$msgno),$n);
-
- if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
-
- if ($contentPart->bytes > 0) {
-
- $contentDP = $contentPart->dparameters;
-
- if ($contentDP[0]->attribute == "filename") {
-
- $fileName = $contentDP[0]->value;
- $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
-
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
-
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
-
- if (!file_exists("$filePath/$fileName")) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
- }
- }
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
}
+
+ foreach ($emailMessage->attachments as $key => $attachment) {
- if (($contentPart->subtype == "GIF") or ($contentPart->subtype == "JPEG") or ($contentPart->subtype == "PNG")) {
-
- if ($contentPart->bytes > 0) {
-
- $contentDP = $contentPart->parameters;
+ $fileContent = $attachment[data];
- if ($contentDP[0]->attribute == "name") {
+ if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
+ $fileName = $key;
+ }
+ else {
+ $fileName = $attachment[filename];
+ }
- $fileName = $contentDP[0]->value;
- $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+ }
+ }
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
+ $bodyTEXT = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $bodyHTML = get_part($mbox, $msgno, "TEXT/HTML");
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
+ if ($bodyHTML != "") {
- if (!file_exists("$filePath/$fileName")) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
+ $msgBody = $bodyHTML;
- if (!is_image("$filePath/$fileName")) {
- unlink("$filePath/$fileName");
- }
- }
- }
- }
- }
+ if (stristr($msgBody,'src="cid:')) {
+ $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
+ }
- $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
- $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
-
- if ($dataHtml != "") {
- $msgBody = $dataHtml;
+ if (stristr($msgBody,'src=cid:')) {
+ $msgBody = str_ireplace('src=cid:',"src=$filePath/",$msgBody);
+ }
}
else {
- $msgBody = trim($dataTxt);
- $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = trim($bodyTEXT);
+ $msgBody = nl2br($msgBody);
$msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
$msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
$msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
}
- // http://www.phpclasses.org/discuss/package/3324/thread/11/
-
- if (stristr($msgBody,'src="cid:')) {
-
- $cid_pass1 = '/src="cid:(.*?)"/si';
- preg_match($cid_pass1,$msgBody,$cid_out1);
-
- $cid_pass2 = '/@(.*?)"/si';
- preg_match($cid_pass2,$cid_out1[0],$cid_out2);
-
- $msgBody = str_ireplace($cid_out2[0],'"',$msgBody);
- $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
- }
-
$msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
$msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno,FT_UID)));
-//echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
-
$get_fromaddress = extract_emails_from($header->fromaddress);
$get_fromaddress = explode("@",$get_fromaddress[0]);
tree bdab3800b728268965ebb73693cd7f835724493f
parent 9152992e8ba5f9213e2a9c46b93db7cff3be730b
author Engels Antonio <engels@majcms.org> 1333690674 +0800
committer Engels Antonio <engels@majcms.org> 1333690674 +0800
Improve extraction of mail attachments
diff --git a/core.php b/core.php
index 1c570f8..791b31f 100644
--- a/core.php
+++ b/core.php
@@ -75,6 +75,9 @@ function HumanReadableFilesize($size) {
return round($size, 2) . ' ' . $units[$i];
}
+
+// cleong@organic.com
+
function get_mime_type(&$struct) {
$primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
@@ -190,11 +193,141 @@ function is_image($path) {
$image_type = $a[2];
if (in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG , IMAGETYPE_BMP))) {
-
return true;
}
return false;
}
+
+// chris@isavvy.co.nz
+
+class EmailMessage {
+
+ protected $connection;
+ protected $messageNumber;
+
+ public $attachments;
+
+ public $getAttachments = true;
+
+ public function __construct($connection, $messageNumber) {
+
+ $this->connection = $connection;
+ $this->messageNumber = $messageNumber;
+ }
+
+ public function fetch() {
+
+ $structure = @imap_fetchstructure($this->connection, $this->messageNumber);
+
+ if (!$structure) {
+ return false;
+ }
+ else {
+ $this->recurse($structure->parts);
+ return true;
+ }
+
+ }
+
+ public function recurse($messageParts, $prefix = '', $index = 1, $fullPrefix = true) {
+
+ foreach ($messageParts as $part) {
+
+ $partNumber = $prefix . $index;
+
+ if ($part->type == 2) {
+
+ $msg = new EmailMessage($this->connection, $this->messageNumber);
+ $msg->getAttachments = $this->getAttachments;
+ $msg->recurse($part->parts, $partNumber.'.', 0, false);
+
+ $this->attachments[] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => '',
+ 'data' => $msg,
+ 'inline' => false,
+ );
+ }
+ elseif (isset($part->parts)) {
+
+ if ($fullPrefix) {
+ $this->recurse($part->parts, $prefix.$index.'.');
+ }
+ else {
+ $this->recurse($part->parts, $prefix);
+ }
+ }
+ elseif ($part->type > 2) {
+
+ if (isset($part->id)) {
+
+ $id = str_replace(array('<', '>'), '', $part->id);
+
+ $this->attachments[$id] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => $this->getFilenameFromPart($part),
+ 'data' => $this->getAttachments ? $this->getPart($partNumber, $part->encoding) : '',
+ 'inline' => true,
+ );
+ }
+ else {
+ $this->attachments[] = array(
+ 'type' => $part->type,
+ 'subtype' => $part->subtype,
+ 'filename' => $this->getFilenameFromPart($part),
+ 'data' => $this->getAttachments ? $this->getPart($partNumber, $part->encoding) : '',
+ 'inline' => false,
+ );
+ }
+ }
+ $index++;
+ }
+ }
+
+ function getPart($partNumber, $encoding) {
+
+ $data = imap_fetchbody($this->connection, $this->messageNumber, $partNumber);
+
+ switch($encoding) {
+
+ case 0: return $data; // 7BIT
+ case 1: return $data; // 8BIT
+ case 2: return $data; // BINARY
+ case 3: return base64_decode($data); // BASE64
+ case 4: return quoted_printable_decode($data); // QUOTED_PRINTABLE
+ case 5: return $data; // OTHER
+ }
+ }
+
+ function getFilenameFromPart($part) {
+
+ $filename = '';
+
+ if ($part->ifdparameters) {
+
+ foreach ($part->dparameters as $object) {
+
+ if (strtolower($object->attribute) == 'filename') {
+ $filename = $object->value;
+ }
+ }
+ }
+
+ if (!$filename && $part->ifparameters) {
+
+ foreach ($part->parameters as $object) {
+
+ if (strtolower($object->attribute) == 'name') {
+ $filename = $object->value;
+ }
+ }
+ }
+ return $filename;
+ }
+}
+
?>
diff --git a/folders.php b/folders.php
index d351752..f04cb1d 100644
--- a/folders.php
+++ b/folders.php
@@ -27,7 +27,6 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
- //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
echo "</form>";
}
@@ -49,7 +48,6 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
- //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
echo "</form>";
}
diff --git a/preload.php b/preload.php
index 9f1ae4f..8df500c 100644
--- a/preload.php
+++ b/preload.php
@@ -1,21 +1,9 @@
-<img src="images/ajax-loader.gif">
-<img src="images/attach.png">
-<img src="images/disable.png">
-<img src="images/enable.png">
-<img src="images/file.png">
-<img src="images/folder-close.png">
-<img src="images/folder-open.png">
-<img src="images/mail-forward.png">
-<img src="images/mail-new.png">
-<img src="images/mail-next.png">
-<img src="images/mail-prev.png">
-<img src="images/mail-read.png">
-<img src="images/mail-replied.png">
-<img src="images/mail-reply-all.png">
-<img src="images/mail-reply.png">
-<img src="images/mail-search.png">
-<img src="images/mail-settings.png">
-<img src="images/mail-unread.png">
-<img src="images/trashcan_empty.png">
-<img src="images/trashcan_full.png">
-<img src="images/trashcan_purge.png">
+<?php
+
+$preload_images = glob("images/{*.gif,*.jpg,*.png}",GLOB_BRACE);
+
+foreach ($preload_images as $preload_image) {
+ echo "<img src=\"$preload_image\">";
+}
+
+?>
diff --git a/read.php b/read.php
index 6b71992..2ba6b31 100644
--- a/read.php
+++ b/read.php
@@ -292,101 +292,58 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $struct = imap_fetchstructure($mbox, $msgno, FT_UID);
+ $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
+ $emailMessage->fetch();
- $contentParts = count($struct->parts);
+ if (count($emailMessage->attachments > 0)) {
- for ($n = 0; $n <= $contentParts; $n++) {
-
- $contentPart = imap_bodystruct($mbox,imap_msgno($mbox,$msgno),$n);
-
- if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
-
- if ($contentPart->bytes > 0) {
-
- $contentDP = $contentPart->dparameters;
-
- if ($contentDP[0]->attribute == "filename") {
-
- $fileName = $contentDP[0]->value;
- $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
-
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
-
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
-
- if (!file_exists("$filePath/$fileName")) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
- }
- }
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
}
+
+ foreach ($emailMessage->attachments as $key => $attachment) {
- if (($contentPart->subtype == "GIF") or ($contentPart->subtype == "JPEG") or ($contentPart->subtype == "PNG")) {
-
- if ($contentPart->bytes > 0) {
-
- $contentDP = $contentPart->parameters;
+ $fileContent = $attachment[data];
- if ($contentDP[0]->attribute == "name") {
+ if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
+ $fileName = $key;
+ }
+ else {
+ $fileName = $attachment[filename];
+ }
- $fileName = $contentDP[0]->value;
- $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$fileName);
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+ }
+ }
- $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$n,FT_UID));
+ $bodyTEXT = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $bodyHTML = get_part($mbox, $msgno, "TEXT/HTML");
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
+ if ($bodyHTML != "") {
- if (!file_exists("$filePath/$fileName")) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
+ $msgBody = $bodyHTML;
- if (!is_image("$filePath/$fileName")) {
- unlink("$filePath/$fileName");
- }
- }
- }
- }
- }
+ if (stristr($msgBody,'src="cid:')) {
+ $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
+ }
- $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
- $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
-
- if ($dataHtml != "") {
- $msgBody = $dataHtml;
+ if (stristr($msgBody,'src=cid:')) {
+ $msgBody = str_ireplace('src=cid:',"src=$filePath/",$msgBody);
+ }
}
else {
- $msgBody = trim($dataTxt);
- $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = trim($bodyTEXT);
+ $msgBody = nl2br($msgBody);
$msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
$msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
$msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
}
- // http://www.phpclasses.org/discuss/package/3324/thread/11/
-
- if (stristr($msgBody,'src="cid:')) {
-
- $cid_pass1 = '/src="cid:(.*?)"/si';
- preg_match($cid_pass1,$msgBody,$cid_out1);
-
- $cid_pass2 = '/@(.*?)"/si';
- preg_match($cid_pass2,$cid_out1[0],$cid_out2);
-
- $msgBody = str_ireplace($cid_out2[0],'"',$msgBody);
- $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
- }
-
$msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
$msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
-//echo nl2br(htmlentities(imap_fetchheader($mbox,$msgno,FT_UID)));
-//echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
-
$get_fromaddress = extract_emails_from($header->fromaddress);
$get_fromaddress = explode("@",$get_fromaddress[0]);