new methods added to message class
This commit is contained in:
parent
a7b914c93f
commit
72b991fa50
|
@ -182,6 +182,24 @@ class Connection
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check MailBox Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$data = imap_check($this->stream);
|
||||
|
||||
return [
|
||||
'date' => (isset($data->Date)) ? $data->Date : false,
|
||||
'driver' => (isset($data->Driver)) ? $data->Driver : false,
|
||||
'mailbox' => (isset($data->Mailbox)) ? $data->Mailbox : false,
|
||||
'nmsgs' => (isset($data->Nmsgs)) ? $data->Nmsgs : false,
|
||||
'recent' => (isset($data->Recent)) ? $data->Recent : false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping Connection
|
||||
*
|
||||
|
|
|
@ -22,7 +22,12 @@ class Message
|
|||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
protected $uid;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $msg_number;
|
||||
|
||||
/**
|
||||
* Message Constructor
|
||||
|
@ -35,23 +40,109 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Message ID
|
||||
* Set Message Number
|
||||
*
|
||||
* @param integer $id
|
||||
* @return void
|
||||
* @return Message
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setMsgNo($msg_number)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->msg_number = $msg_number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Message ID
|
||||
* Get Message Number
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
public function getMsgNo()
|
||||
{
|
||||
return $this->id;
|
||||
return $this->msg_number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set UID
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return Message
|
||||
*/
|
||||
public function setUid($uid)
|
||||
{
|
||||
$this->uid = $uid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UID
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getUid()
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Config Message Number & UID
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
if( !this->msg_number && $this->uid ){
|
||||
$this->msg_number = imap_msgno($this->connection->getStream(), $this->uid);
|
||||
}
|
||||
|
||||
if( !this->uid && $this->msg_number ){
|
||||
$this->uid = imap_uid($this->connection->getStream(), $this->msg_number);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Body
|
||||
*
|
||||
* @param integer $options
|
||||
* @return string
|
||||
*/
|
||||
public function getBody($options = 0)
|
||||
{
|
||||
$body = imap_body($this->connection->getStream(), $this->msg_number, $options);
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Address List
|
||||
*
|
||||
* @param string $address_string
|
||||
* @return array
|
||||
*/
|
||||
public function parseAddressList($address_string, $default_host = "example.com")
|
||||
{
|
||||
$address_array = imap_rfc822_parse_adrlist($address_string, $default_host);
|
||||
$address_list = [];
|
||||
|
||||
foreach ($address_array as $id => $val) {
|
||||
$address_list[] = [
|
||||
'mailbox' => $val->mailbox,
|
||||
'host' => $val->host,
|
||||
'personal' => $val->personal,
|
||||
'adl' => $val->adl
|
||||
];
|
||||
}
|
||||
|
||||
return $address_list;
|
||||
}
|
||||
|
||||
|
||||
// imap_fetchbody
|
||||
// imap_fetchheader
|
||||
// imap_fetchstructure
|
||||
// imap_fetch_overview
|
||||
|
||||
}
|
Loading…
Reference in a new issue