From 21b65ab2e79351a42a7f9f55671f317cf5fd7d54 Mon Sep 17 00:00:00 2001 From: Anthony Kuske Date: Thu, 16 Oct 2014 14:30:59 +0100 Subject: [PATCH 1/2] Attachments include inline images --- src/MS/Email/Parser/Parser.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/MS/Email/Parser/Parser.php b/src/MS/Email/Parser/Parser.php index 10d4594..d01442d 100644 --- a/src/MS/Email/Parser/Parser.php +++ b/src/MS/Email/Parser/Parser.php @@ -19,7 +19,7 @@ public function parse($email){ $this->getHeader('subject'), $this->getText(), $this->getHtml(), - $this->getAttachments(), + $this->getAllAttachments(), $this->getHeader('date') ); } @@ -39,8 +39,20 @@ protected function getText(){ } protected function getAttachments(){ + return $this->getAttachmentsFromPart('/attachment/'); + } + + protected function getInlineAttachments(){ + return $this->getAttachmentsFromPart('/inline/'); + } + + protected function getAllAttachments(){ + return array_merge($this->getAttachments(), $this->getInlineAttachments()); + } + + private function getAttachmentsFromPart($part){ if(!is_array($this->parts['body'])) return false; - $attachments = $this->searchByHeader('/content\-disposition/','/attachment/'); + $attachments = $this->searchByHeader('/content\-disposition/', $part); $attachments = $attachments ? $attachments : array(); $attachmentObjects = array(); From 975c52ee88b45141b93d40739b3ebab0227d019b Mon Sep 17 00:00:00 2001 From: Anthony Kuske Date: Thu, 16 Oct 2014 14:33:48 +0100 Subject: [PATCH 2/2] Version bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d804739..8ba9c43 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "michaelesmith/email-parser", - "version": "0.2", + "version": "0.3", "description": "Parse an email into an object representation", "keywords": ["email", "parse"], "homepage": "https://github.com/michaelesmith/EmailParser",