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