diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index 9b08fad..8dffa6f 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -54,7 +54,7 @@ class Server * * @var string */ - protected $mailbox; + protected $mailbox = ''; /** * This is the username used to connect to the server. @@ -151,13 +151,19 @@ class Server * This function sets the mailbox to connect to. * * @param string $mailbox + * @return bool */ public function setMailBox($mailbox = '') { + if(!$this->hasMailBox($mailbox)) + return false; + $this->mailbox = $mailbox; if (isset($this->imapStream)) { $this->setImapStream(); } + + return true; } public function getMailBox() @@ -365,6 +371,17 @@ class Server return $messages; } + public function getMessageByUid($uid) + { + try { + $message = new \Fetch\Message($uid, $this); + return $message; + }catch(\Exception $e){ + return false; + } + } + + /** * This function removes all of the messages flagged for deletion from the mailbox. *