mirror of
https://github.com/retailcrm/Fetch.git
synced 2025-02-06 10:39:21 +03:00
Improved error handling in Server class, added getMessageByUid method
This commit is contained in:
parent
0bbc02b006
commit
eda6cc65ab
@ -54,7 +54,7 @@ class Server
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $mailbox;
|
protected $mailbox = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the username used to connect to the server.
|
* This is the username used to connect to the server.
|
||||||
@ -151,13 +151,19 @@ class Server
|
|||||||
* This function sets the mailbox to connect to.
|
* This function sets the mailbox to connect to.
|
||||||
*
|
*
|
||||||
* @param string $mailbox
|
* @param string $mailbox
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setMailBox($mailbox = '')
|
public function setMailBox($mailbox = '')
|
||||||
{
|
{
|
||||||
|
if(!$this->hasMailBox($mailbox))
|
||||||
|
return false;
|
||||||
|
|
||||||
$this->mailbox = $mailbox;
|
$this->mailbox = $mailbox;
|
||||||
if (isset($this->imapStream)) {
|
if (isset($this->imapStream)) {
|
||||||
$this->setImapStream();
|
$this->setImapStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMailBox()
|
public function getMailBox()
|
||||||
@ -365,6 +371,17 @@ class Server
|
|||||||
return $messages;
|
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.
|
* This function removes all of the messages flagged for deletion from the mailbox.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user