Skip to content

Commit

Permalink
Merge pull request #14 from portrino/master
Browse files Browse the repository at this point in the history
3 new accessing methods for the inbox
  • Loading branch information
ericmartel authored Oct 19, 2017
2 parents 9762a21 + 5767d0c commit 192f1cf
Showing 1 changed file with 75 additions and 19 deletions.
94 changes: 75 additions & 19 deletions src/MailHog.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +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) {
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);
}

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);
}

/**
* 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();

if (isset($email->Content->Headers->Cc) && array_search($address, $email->Content->Headers->Cc)) {
array_push($inbox, $email);
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();

if (isset($email->Content->Headers->Bcc) && array_search($address, $email->Content->Headers->Bcc)) {
array_push($inbox, $email);
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 192f1cf

Please sign in to comment.