From aabacffbd2ac9578e19136ab562a97aa1648252a Mon Sep 17 00:00:00 2001 From: Al Brookbanks Date: Fri, 1 May 2015 17:08:13 +0100 Subject: [PATCH] Added public function getFrom --- PlancakeEmailParser.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PlancakeEmailParser.php b/PlancakeEmailParser.php index 59e6cee..90bd6d4 100644 --- a/PlancakeEmailParser.php +++ b/PlancakeEmailParser.php @@ -154,6 +154,20 @@ public function getCc() return explode(',', $this->rawFields['cc']); } + + /** + * + * @return array + * @throws Exception if a to header is not found or if there are no recipient + */ + public function getFrom() + { + if ( (!isset($this->rawFields['from'])) || (!count($this->rawFields['from']))) + { + throw new Exception("Couldn't find the recipients of the email"); + } + return explode(',', $this->rawFields['from']); + } /** *