Updated Message class to throw exception when passed nonexistant email ID

This commit is contained in:
Robert Hafner 2013-12-18 14:19:39 -08:00
parent 7af83a84db
commit 0bbc02b006

View File

@ -175,7 +175,8 @@ class Message
$this->imapConnection = $mailbox; $this->imapConnection = $mailbox;
$this->uid = $messageUniqueId; $this->uid = $messageUniqueId;
$this->imapStream = $this->imapConnection->getImapStream(); $this->imapStream = $this->imapConnection->getImapStream();
$this->loadMessage(); if($this->loadMessage() !== true)
throw new \RuntimeException('Message with ID ' . $messageUniqueId . ' not found.');
} }
/** /**
@ -188,7 +189,8 @@ class Message
/* First load the message overview information */ /* First load the message overview information */
$messageOverview = $this->getOverview(); if(!is_object($messageOverview = $this->getOverview()))
return false;
$this->subject = $messageOverview->subject; $this->subject = $messageOverview->subject;
$this->date = strtotime($messageOverview->date); $this->date = strtotime($messageOverview->date);
@ -225,6 +227,8 @@ class Message
foreach ($structure->parts as $id => $part) foreach ($structure->parts as $id => $part)
$this->processStructure($part, $id + 1); $this->processStructure($part, $id + 1);
} }
return true;
} }
/** /**