Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Mail_Storage_Pop3 Class Reference
Inheritance diagram for Zend_Mail_Storage_Pop3:
Zend_Mail_Storage_Abstract

Public Member Functions

 countMessages ()
 
 getSize ($id=0)
 
 getMessage ($id)
 
 getRawHeader ($id, $part=null, $topLines=0)
 
 getRawContent ($id, $part=null)
 
 __construct ($params)
 
 close ()
 
 noop ()
 
 removeMessage ($id)
 
 getUniqueId ($id=null)
 
 getNumberByUniqueId ($id)
 
 __get ($var)
 
- Public Member Functions inherited from Zend_Mail_Storage_Abstract
 __get ($var)
 
 getCapabilities ()
 
 countMessages ()
 
 getSize ($id=0)
 
 getMessage ($id)
 
 getRawHeader ($id, $part=null, $topLines=0)
 
 getRawContent ($id, $part=null)
 
 __construct ($params)
 
 __destruct ()
 
 close ()
 
 noop ()
 
 removeMessage ($id)
 
 getUniqueId ($id=null)
 
 getNumberByUniqueId ($id)
 
 count ()
 
 offsetExists ($id)
 
 offsetGet ($id)
 
 offsetSet ($id, $value)
 
 offsetUnset ($id)
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 seek ($pos)
 

Protected Attributes

 $_protocol
 
- Protected Attributes inherited from Zend_Mail_Storage_Abstract
 $_has
 
 $_iterationPos = 0
 
 $_iterationMax = null
 
 $_messageClass = 'Zend_Mail_Message'
 

Detailed Description

Definition at line 47 of file Pop3.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $params)

create instance with parameters Supported paramters are

  • host hostname or ip address of POP3 server
  • user username
  • password password for user 'username' [optional, default = '']
  • port port for POP3 server [optional, default = 110]
  • ssl 'SSL' or 'TLS' for secure sockets
Parameters
array$paramsmail reader specific parameters
Exceptions
Zend_Mail_Storage_Exception
Zend_Mail_Protocol_Exception
See also
Zend_Mail_Storage_Exception

Definition at line 161 of file Pop3.php.

162  {
163  if (is_array($params)) {
164  $params = (object)$params;
165  }
166 
167  $this->_has['fetchPart'] = false;
168  $this->_has['top'] = null;
169  $this->_has['uniqueid'] = null;
170 
171  if ($params instanceof Zend_Mail_Protocol_Pop3) {
172  $this->_protocol = $params;
173  return;
174  }
175 
176  if (!isset($params->user)) {
180  #require_once 'Zend/Mail/Storage/Exception.php';
181  throw new Zend_Mail_Storage_Exception('need at least user in params');
182  }
183 
184  $host = isset($params->host) ? $params->host : 'localhost';
185  $password = isset($params->password) ? $params->password : '';
186  $port = isset($params->port) ? $params->port : null;
187  $ssl = isset($params->ssl) ? $params->ssl : false;
188 
189  $this->_protocol = new Zend_Mail_Protocol_Pop3();
190  $this->_protocol->connect($host, $port, $ssl);
191  $this->_protocol->login($params->user, $password);
192  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

Member Function Documentation

◆ __get()

__get (   $var)

Special handling for hasTop and hasUniqueid. The headers of the first message is retrieved if Top wasn't needed/tried yet.

See also
Zend_Mail_Storage_Abstract:__get()
Parameters
string$var
Returns
string
Exceptions
Zend_Mail_Storage_Exception

Definition at line 295 of file Pop3.php.

296  {
297  $result = parent::__get($var);
298  if ($result !== null) {
299  return $result;
300  }
301 
302  if (strtolower($var) == 'hastop') {
303  if ($this->_protocol->hasTop === null) {
304  // need to make a real call, because not all server are honest in their capas
305  try {
306  $this->_protocol->top(1, 0, false);
307  } catch(Zend_Mail_Exception $e) {
308  // ignoring error
309  }
310  }
311  $this->_has['top'] = $this->_protocol->hasTop;
312  return $this->_protocol->hasTop;
313  }
314 
315  if (strtolower($var) == 'hasuniqueid') {
316  $id = null;
317  try {
318  $id = $this->_protocol->uniqueid(1);
319  } catch(Zend_Mail_Exception $e) {
320  // ignoring error
321  }
322  $this->_has['uniqueid'] = $id ? true : false;
323  return $this->_has['uniqueid'];
324  }
325 
326  return $result;
327  }
$id
Definition: fieldset.phtml:14

◆ close()

close ( )

Close resource for mail lib. If you need to control, when the resource is closed. Otherwise the destructor would call this.

Returns
null

Definition at line 200 of file Pop3.php.

201  {
202  $this->_protocol->logout();
203  }

◆ countMessages()

countMessages ( )

Count messages all messages in current box

Returns
int number of messages
Exceptions
Zend_Mail_Storage_Exception
Zend_Mail_Protocol_Exception

Definition at line 63 of file Pop3.php.

64  {
65  $this->_protocol->status($count, $null);
66  return (int)$count;
67  }
$count
Definition: recent.phtml:13

◆ getMessage()

getMessage (   $id)

Fetch a message

Parameters
int$idnumber of message
Returns
Zend_Mail_Message
Exceptions
Zend_Mail_Protocol_Exception

Definition at line 89 of file Pop3.php.

90  {
91  $bodyLines = 0;
92  $message = $this->_protocol->top($id, $bodyLines, true);
93 
94  return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $message,
95  'noToplines' => $bodyLines < 1));
96  }
$id
Definition: fieldset.phtml:14
$message

◆ getNumberByUniqueId()

getNumberByUniqueId (   $id)

get a message number from a unique id

I.e. if you have a webmailer that supports deleting messages you should use unique ids as parameter and use this method to translate it to message number right before calling removeMessage()

Parameters
string$idunique id
Returns
int message number
Exceptions
Zend_Mail_Storage_Exception
See also
Zend_Mail_Storage_Exception

Definition at line 266 of file Pop3.php.

267  {
268  if (!$this->hasUniqueid) {
269  return $id;
270  }
271 
272  $ids = $this->getUniqueId();
273  foreach ($ids as $k => $v) {
274  if ($v == $id) {
275  return $k;
276  }
277  }
278 
282  #require_once 'Zend/Mail/Storage/Exception.php';
283  throw new Zend_Mail_Storage_Exception('unique id not found');
284  }
$id
Definition: fieldset.phtml:14
getUniqueId($id=null)
Definition: Pop3.php:239

◆ getRawContent()

getRawContent (   $id,
  $part = null 
)
See also
Zend_Mail_Storage_Exception

Definition at line 131 of file Pop3.php.

132  {
133  if ($part !== null) {
134  // TODO: implement
138  #require_once 'Zend/Mail/Storage/Exception.php';
139  throw new Zend_Mail_Storage_Exception('not implemented');
140  }
141 
142  $content = $this->_protocol->retrieve($id);
143  // TODO: find a way to avoid decoding the headers
145  return $body;
146  }
$id
Definition: fieldset.phtml:14
static splitMessage( $message, &$headers, &$body, $EOL=Zend_Mime::LINEEND)
Definition: Decode.php:123

◆ getRawHeader()

getRawHeader (   $id,
  $part = null,
  $topLines = 0 
)
See also
Zend_Mail_Storage_Exception

Definition at line 108 of file Pop3.php.

109  {
110  if ($part !== null) {
111  // TODO: implement
115  #require_once 'Zend/Mail/Storage/Exception.php';
116  throw new Zend_Mail_Storage_Exception('not implemented');
117  }
118 
119  return $this->_protocol->top($id, 0, true);
120  }
$id
Definition: fieldset.phtml:14

◆ getSize()

getSize (   $id = 0)

get a list of messages with number and size

Parameters
int$idnumber of message
Returns
int|array size of given message of list with all messages as array(num => size)
Exceptions
Zend_Mail_Protocol_Exception

Definition at line 76 of file Pop3.php.

77  {
78  $id = $id ? $id : null;
79  return $this->_protocol->getList($id);
80  }
$id
Definition: fieldset.phtml:14

◆ getUniqueId()

getUniqueId (   $id = null)

get unique id for one or all messages

if storage does not support unique ids it's the same as the message number

Parameters
int | null$idmessage number
Returns
array|string message number for given message or all messages as array
Exceptions
Zend_Mail_Storage_Exception

Definition at line 239 of file Pop3.php.

240  {
241  if (!$this->hasUniqueid) {
242  if ($id) {
243  return $id;
244  }
245  $count = $this->countMessages();
246  if ($count < 1) {
247  return array();
248  }
249  $range = range(1, $count);
250  return array_combine($range, $range);
251  }
252 
253  return $this->_protocol->uniqueid($id);
254  }
$id
Definition: fieldset.phtml:14
$count
Definition: recent.phtml:13

◆ noop()

noop ( )

Keep the server busy.

Returns
null
Exceptions
Zend_Mail_Protocol_Exception

Definition at line 211 of file Pop3.php.

212  {
213  return $this->_protocol->noop();
214  }

◆ removeMessage()

removeMessage (   $id)

Remove a message from server. If you're doing that from a web enviroment you should be careful and use a uniqueid as parameter if possible to identify the message.

Parameters
int$idnumber of message
Returns
null
Exceptions
Zend_Mail_Protocol_Exception

Definition at line 225 of file Pop3.php.

226  {
227  $this->_protocol->delete($id);
228  }
$id
Definition: fieldset.phtml:14

Field Documentation

◆ $_protocol

$_protocol
protected

Definition at line 53 of file Pop3.php.


The documentation for this class was generated from the following file: