Reputation: 2358
I'm trying to get all the emails sent from a specific email which are either sent this month or last month. I'm using the following code:
(note: the imap_open works, I put 3 dots since I can't show the connection details)
$imapStream = imap_open(...);
if (!$imapStream || !empty(imap_errors())) {
return;
}
$emailIds = imap_search($imapStream, 'FROM ' . $email . ' SINCE ' . date ( "d M Y", strToTime ( "-1 month" ) ));
Where $email
is a POST
parameter. However, when I run this, it doesn't give me all the emails. When looking into imap_errors()
, it gives the following error:
Unknown search criterion: SINCE
Upvotes: 1
Views: 1620
Reputation: 2358
Found the error. imap somehow doesn't give me the right errors.
I tried this line:
$emailIds = imap_search($imapStream, 'FROM "' . $email . '" SINCE 22-Jul-2012');
This worked. So the SINCE
criterion wasn't unknown the date string wasn't right.
Upvotes: 3