diff --git a/composer.json b/composer.json index 7ba7d43..df34b36 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require": { - "ericmartel/codeception-email": "dev-master", + "ericmartel/codeception-email": "^1.0", "guzzlehttp/guzzle": "^6.1" }, "autoload": { diff --git a/src/MailHog.php b/src/MailHog.php index 1d50649..bdf5c05 100644 --- a/src/MailHog.php +++ b/src/MailHog.php @@ -143,19 +143,20 @@ public function fetchEmails() public function accessInboxFor($address) { $inbox = array(); + foreach($this->fetchedEmails as $email) { - if(!isset($email->Content->Headers->Bcc)) - { - if(strpos($email->Content->Headers->To[0], $address) !== FALSE || (isset($email->Content->Headers->Cc) && array_search($address, $email->Content->Headers->Cc))) - { - array_push($inbox, $email); + if (strpos($email->Content->Headers->To[0], $address) !== false) { + array_push($inbox, $email); + } + + if (isset($email->Content->Headers->Cc) && array_search($address, $email->Content->Headers->Cc)) { + array_push($inbox, $email); + } + + if (isset($email->Content->Headers->Bcc) && array_search($address, $email->Content->Headers->Bcc)) { + array_push($inbox, $email); } - } - else if(strpos($email->Content->Headers->Bcc[0], $address) !== FALSE) - { - array_push($inbox, $email); - } } $this->setCurrentInbox($inbox); }