V
V
v3shin2017-05-24 13:35:00
PHP
v3shin, 2017-05-24 13:35:00

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; // смотрим только одно письмо
}

No heavy calculations are made inside the class. An example of the Imap->searchUnseen() function:
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);
}

Everything works, but at the output I get such a debug table, despite the fact that there are no more than 500 letters in the mailbox
a34c39bc7e144345a169f15a7de49074.png
:
sudo apt-get install php5-imap
sudo php5enmod imap
sudo service apache2 restart

php version:
PHP 5.6.4-4ubuntu6.4 (cli) (built: Oct 28 2015 01:21:29)

Actually, the question is: how to speed it up?
Well, or how to set up logging and debug the connection, because the log is not written to /var/log/maillog?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question