diff --git a/src/Pop3.php b/src/Pop3.php index c5ff4e1..e3cd077 100644 --- a/src/Pop3.php +++ b/src/Pop3.php @@ -245,6 +245,7 @@ public function getEmails($start = 0, $range = 10) ->test(2, 'int'); $total = $this->getEmailTotal(); + $total = $total['messages']; if ($total == 0) { return array(); @@ -316,6 +317,7 @@ public function remove($msgno) foreach ($msgno as $number) { $this->call('DELE '.$number); + } return $this; @@ -661,12 +663,15 @@ private function getParts($content, array $parts = array()) { //separate the head and the body list($head, $body) = preg_split("/\n\s*\n/", $content, 2); + //front()->output($head); //get the headers $head = $this->getHeaders($head); //if content type is not set if (!isset($head['content-type'])) { return $parts; } + + //split the content type if (is_array($head['content-type'])) { @@ -694,7 +699,7 @@ private function getParts($content, array $parts = array()) $attr = explode('=', $attr, 2); if (count($attr) > 1) { list($key, $value) = $attr; - $extra[strtolower($key)] = $value; + $extra[$key] = $value; } unset($extra[$i]); } @@ -739,11 +744,18 @@ private function getParts($content, array $parts = array()) if (isset($extra['name'])) { //add to parts $parts['attachment'][$extra['name']][$type] = $body; + + /* To show embedded image we need CID and that comes with this x-attachment-id, require specially for gmail. */ + if (isset($head['x-attachment-id'])) + $parts['attachment'][$extra['name']]['x-attachment-id'] = $head['x-attachment-id']; + } else { //it's just a regular body //add to parts $parts[$type] = $body; } + + } return $parts; }