- while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) {
- if (substr($read, 0, 3) == "To:") {
- $read = ereg_replace("<", "<", $read);
- $read = ereg_replace(">", ">", $read);
- $to[$pos] = substr($read, 3, strlen($read));
- if (strlen(Chop($to[$pos])) == 0)
- $to[$pos] = "Unknown Recipients";
+ /** Now, lets work out the MIME stuff **/
+ /** (needs mime.php included) **/
+ return decodeMime($body, $bound, $type0, $type1);
+ }
+
+ function fetchEntityHeader($imapConnection, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
+ /** defaults... if the don't get overwritten, it will display text **/
+ $type0 = "text";
+ $type1 = "plain";
+ $encoding = "us-ascii";
+ $i = 0;
+ while (trim($read[$i]) != "") {
+ if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") {
+ $encoding = strtolower(trim(substr($read[$i], 26)));
+
+ } else if (substr($read[$i], 0, 13) == "Content-Type:") {
+ $cont = strtolower(trim(substr($read[$i], 13)));
+ if (strpos($cont, ";"))
+ $cont = substr($cont, 0, strpos($cont, ";"));
+
+ if (strpos($cont, "/")) {
+ $type0 = substr($cont, 0, strpos($cont, "/"));
+ $type1 = substr($cont, strpos($cont, "/")+1);
+ } else {
+ $type0 = $cont;