From 45e7a136ceab6d6b4101cdcb7af64ac765af9edb Mon Sep 17 00:00:00 2001 From: Scott Phillips Date: Thu, 12 Jul 2018 10:15:42 -0500 Subject: [PATCH] Check for date header before using them. --- src/MailHog.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/MailHog.php b/src/MailHog.php index acbfc36..f77561c 100644 --- a/src/MailHog.php +++ b/src/MailHog.php @@ -511,8 +511,14 @@ protected function sortEmails($inbox) */ static function sortEmailsByCreationDatePredicate($emailA, $emailB) { - $sortKeyA = $emailA->Content->Headers->Date; - $sortKeyB = $emailB->Content->Headers->Date; - return ($sortKeyA > $sortKeyB) ? -1 : 1; + if (isset($emailA->Content->Headers->Date) && isset($emailA->Content->Headers->Date)) { + $sortKeyA = $emailA->Content->Headers->Date; + $sortKeyB = $emailB->Content->Headers->Date; + return ($sortKeyA > $sortKeyB) ? -1 : 1; + } + else { + return -1; + } + } }