B
B
Barmunk2019-04-16 12:26:49
PHP
Barmunk, 2019-04-16 12:26:49

How to accurately set timeout for php imap_open?

I made a connection to imap yandex mail via cron, it works stably, but sometimes imap_open freezes tightly, without any error. The script can hang for a day in working condition and never end.
I connect by:

{imap.yandex.ru:993/ssl/novalidate-cert}INBOX
{imap.yandex.ru:993/imap/ssl}INBOX

I tried to put in the beginning of the script:
set_time_limit(20);
ini_set("default_socket_timeout", 20);
imap_timeout(IMAP_READTIMEOUT, 20);
imap_timeout(IMAP_OPENTIMEOUT, 20);
imap_timeout(IMAP_WRITETIMEOUT, 20);
imap_timeout(IMAP_CLOSETIMEOUT, 20);

I logged imap_timeout at the time of connection, "20" is indeed transmitted.
A quick google leads to a php bug with ssl connection, but I'm not sure: https
://stackoverflow.com/questions/55407026/imap-...
https://bugs.php.net/bug.php?id=61846
Yandex.mail seems to have no connection without ssl, at least this connection does not work:
{imap.yandex.ru:143/imap/notls}INBOX

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