Skip to content

Commit

Permalink
* [FEATURE] Adds 3 new methods for accessing inboxes
Browse files Browse the repository at this point in the history
** accessInboxForTo()
** accessInboxForCc()
** accessInboxForBcc()
  • Loading branch information
aWuttig committed Oct 12, 2017
1 parent 094c60d commit 5767d0c
Showing 1 changed file with 79 additions and 15 deletions.
94 changes: 79 additions & 15 deletions src/MailHog.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,89 @@ public function fetchEmails()
$this->setCurrentInbox($this->fetchedEmails);
}

/**
* Access Inbox For
*
* Filters emails to only keep those that are received by the provided address
*
* @param string $address Recipient address' inbox
*/
public function accessInboxFor($address)
{
$inbox = array();
/**
* Access Inbox For *
*
* Filters emails to only keep those that are received by the provided address
*
* @param string $address Recipient address' inbox
*/
public function accessInboxFor($address)
{
$inbox = array();

foreach($this->fetchedEmails as $email)
foreach ($this->fetchedEmails as $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);
}
}
$this->setCurrentInbox($inbox);
}

/**
* Access Inbox For To
*
* Filters emails to only keep those that are received by the provided address
*
* @param string $address Recipient address' inbox
*/
public function accessInboxForTo($address)
{
if (strpos($email->Content->Headers->To[0], $address) !== false) {
array_push($inbox, $email);
$inbox = array();

foreach ($this->fetchedEmails as $email) {
if (strpos($email->Content->Headers->To[0], $address) !== false) {
array_push($inbox, $email);
}
}
$this->setCurrentInbox($inbox);
}

/**
* Access Inbox For CC
*
* Filters emails to only keep those that are received by the provided address
*
* @param string $address Recipient address' inbox
*/
public function accessInboxForCc($address)
{
$inbox = array();

foreach ($this->fetchedEmails as $email) {
if (isset($email->Content->Headers->Cc) && array_search($address, $email->Content->Headers->Cc)) {
array_push($inbox, $email);
}
}
$this->setCurrentInbox($inbox);
}

/**
* Access Inbox For BCC
*
* Filters emails to only keep those that are received by the provided address
*
* @param string $address Recipient address' inbox
*/
public function accessInboxForBcc($address)
{
$inbox = array();

foreach ($this->fetchedEmails as $email) {
if (isset($email->Content->Headers->Bcc) && array_search($address, $email->Content->Headers->Bcc)) {
array_push($inbox, $email);
}
}
$this->setCurrentInbox($inbox);
}
$this->setCurrentInbox($inbox);
}

/**
* Open Next Unread Email
Expand Down

0 comments on commit 5767d0c

Please sign in to comment.