S
S
Sergey Ivchenko2015-12-21 16:37:18
PHP
Sergey Ivchenko, 2015-12-21 16:37:18

Why can't I receive mail via imap with the NEW flag?

The essence of the problem is that I can't get a list of letters by the SUBJECT + NEW filter I need. In the case of a bare SUBJECT, imap_search returns all messages except the last one. At what both filters SUBJECT + NEW and SUBJECT + UNSEEN do not work.

$mbox = imap_open("{imap.yandex.ru:993/imap/ssl}INBOX", "[email protected]", "password");
$mails = imap_search($mbox, 'ALL UNSEEN FROM [email protected] SUBJECT "Zdes kusok temy latinicei i s probelami"');
/*Здесь код обработки полученного mails*/
imap_close($mbox);

This is how receiving letters is now. Changing Unseen to new doesn't work. $mails returns false.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Filatov, 2015-12-21
@NYMEZIDE

try without ALL flag

D
dmitriy, 2015-12-21
@dmitriylanets

1. try to get emails with a simple request SINCE 20-12-2015 FROM "[email protected]"
further expand if successful
2. if $mails == false print imap_last_error()
3. if the error occurs only when working via cron then log important parts of the code
if(!$mbox = imap_open("{imap.yandex.ru:993/imap/ssl}INBOX", "[email protected]", "password")){
$log->add(' error connection'.imap_last_error());
}
if(!$mails = imap_search($mbox, 'ALL UNSEEN FROM [email protected] SUBJECT "Zdes kusok temy latinicei is problami"')){
$log->add('error'. imap_last_error());
}
$log->add('success:'.count($mails));

A
Alex Z., 2016-09-27
@shumaher86

Here they write that it is impossible to search for FROM.
also encountered now. so far I have set up forwarding to Yandex with filters, and I will search from there. though the letter arrives in half an hour for some reason, so the method is worthless

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question