php-imap
php-imap copied to clipboard
How to solve Invalid Message Date
Our company is currently automatically fetching our inbox messages using:
$inboxMessages = $this->inboxFolder->messages()->all()->get();
Occassionaly, we get a bad message in there with an invalid message date, which throws an error and terminates the whole script. If this happens, we manually clear out our inbox that consists of like 500+ messages a day. This is a real struggle, because if we get this error, we have to spend a lot of time searching and fixing it.
Error: GetMessagesFailedException Invalid message date. ID: Date:Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)
Is there some sort of way that we can skip these messages from fetching or like delete them, without editing your whole package @Webklex ?
@Webklex do you know of an easy fix for this, that i can implement at this particular moment?
Hi @dannylifino ,
many thanks for your report. Is this Di., 15 Feb. 2022 06:52:44 +0100 (MEZ)/Di., 15 Feb. 2022 06:52:44 +0100 (MEZ) the actual date string or a combined string from two different messages?
This is our current collection: https://github.com/Webklex/php-imap/blob/0897d64c86eb69cd55d18d2fee2e390868429787/src/Header.php#L708-L744
Please feel free to add an additional rule.
You can also disable this behavior by providing a fallback date fallback_date within your config:
https://github.com/Webklex/php-imap/blob/0897d64c86eb69cd55d18d2fee2e390868429787/src/config/imap.php#L154
Best regards & happy coding,
Same here, I got the similar exception quite often
'Invalid message date. ID*** Date:fr., 25 nov. 2022 06:27:14 +0100/fr., 25 nov. 2022 06:27:14 +0100'
I have same problem on 5.5.0 version :( This is error message: Invalid message date. ID:[email protected] Date:Tue, 22 Feb 2024 19:23:29 +0000k5b3sk0m/Tue, 22 Feb 2024 19:23:29 +0000k5b3sk0m