PHP imap_search UNSEEN SINCE date with time

I am using PHP imap_search to get a list of invisible messages from a specified date as follows:

imap_search($stream, 'UNSEEN SINCE 20-Sep-2015');

It works great. However, I periodically check new emails every few minutes and keep the last scan time in the session. I want to be able to run imap_search with a UNSEEN SINCE date, including time. But that just doesn't work. I tried:

imap_search($stream, 'UNSEEN SINCE 20-Sep-2015 12:35:03 +0000 (UTC)');
imap_search($stream, 'UNSEEN SINCE 20-Sep-2015 12:35:03 +0000');
imap_search($stream, 'UNSEEN SINCE 20-Sep-2015 12:35:03');

Nothing seems to work. Any ideas if this can be done?

+4
source share
2 answers

Looking at the definition SINCEin RFC 3501 :

  SINCE <date>
     Messages whose internal date (disregarding time and timezone)
     is within or later than the specified date.

And datedefined as just a date, without time:

date            = date-text / DQUOTE date-text DQUOTE

date-day        = 1*2DIGIT
                    ; Day of month

date-month      = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"

date-text       = date-day "-" date-month "-" date-year

date-year       = 4DIGIT

, SINCE , , .


- UID , , :

imap_search($stream, 'UID ' . $latest_uid . ':*', SE_UID);

SE_UID , imap_search UID .

+11

, , php IMAP. , IMAP , rfc 5032, , php . , SINCE ( IMAP) , . , , php datetime. . IMAP: rfc 3501

0

Source: https://habr.com/ru/post/1608340/


All Articles