Answer the question
In order to leave comments, you need to log in
How to speed up imap php?
Good day.
There is a task for processing letters from the mail; I use my Imap wrapper class:
$imap = new Imap([
'server' => 'imap.yandex.ru',
'port' => '993',
'flags' => [
'ssl' => true,
],
'login' => $login,
'password' => $password,
'debug' => true, // дебаг внутри класса
], true);
$mails = $imap->searchUnseen();
foreach($mails as $mailNumber){
$header = $imap->header($mailNumber);
$structure = $imap->fetchstructure($mailNumber);
...
break; // смотрим только одно письмо
}
public function search($criteria = 'ALL', $options = SE_FREE, $charset = null){
if($this->debug) $this->updateDebugTime(); // сохраняем текущее время
$ret = imap_search($this->conn, $criteria, $options, $charset);
if($this->debug) $this->addDebug('search', compact('criteria', 'options', 'charset')); // сравниваем время с сохраненным и пишем в дебаг
return $ret;
}
public function searchUnseen($options = SE_FREE, $charset = null){
return $this->search('UNSEEN', $options, $charset);
}
sudo apt-get install php5-imap
sudo php5enmod imap
sudo service apache2 restart
PHP 5.6.4-4ubuntu6.4 (cli) (built: Oct 28 2015 01:21:29)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question