Comments (19)
Hi @GuiAndra ,
thanks for the report. I think I would rather like to validate the given datestring and perhaps "fix it" if it seems to be broken. This way anyone can be sure to always have a valid Carbon object.
Please give me a few days or perhaps the upcomming weekend to come up with a fix :)
Best regards
from laravel-imap.
@Webklex
Fri, 1 Feb 2019 01:30:04 +0600 (+06)
string №346
Fix my exception
case preg_match('/([A-Z]{2,3},\s+[0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\ [-|+][0-9]{4}\ (.*))+$/i', $date) > 0:
work it
from laravel-imap.
For anyone that comes across this in the future, you can switch over to php-imap with very minor changes to your code and you can pass in a fallback_date to deal with errors related to parsing time strings.
https://github.com/Webklex/php-imap/blob/master/src/Header.php#L736
$clientManager = new ClientManager(['options' => ['fallback_date' => Carbon::now()]]);
from laravel-imap.
Sure @Webklex, i'm waiting for the fix.
thanks :)
from laravel-imap.
Hi @GuiAndra,
please update to v 1.0.3.9 :)
from laravel-imap.
Thaanks @Webklex :)
from laravel-imap.
04 Jan 2018 10:12:47 UT is a timestamp I have in one of the emails I'm trying to read. This caused a crash because of Carbon::parse.
Edit: My dirty fix was to replace
try{
$this->date = Carbon::parse($date);
}catch(\Exception $e){
switch(true){
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ \+[0-9]{4}\ \([A-Z]{2,3}\+[0-9]{1,2}\:[0-9]{1,2})\)+$/i', $date):
$array = explode('(', $date);
$array = array_reverse($array);
$date = trim(array_pop($array));
break;
}
$this->date = Carbon::parse($date);
}
with
try{
$this->date = Carbon::parse($date);
}catch(\Exception $e){
switch(true){
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ \+[0-9]{4}\ \([A-Z]{2,3}\+[0-9]{1,2}\:[0-9]{1,2})\)+$/i', $date):
$array = explode('(', $date);
$array = array_reverse($array);
$date = trim(array_pop($array));
break;
}
if(strpos($date, "UT") !== FALSE && strpos($date, "UTC") === FALSE){
$date = str_replace("UT", "UTC", $date);
}
$this->date = Carbon::parse($date);
}
in https://github.com/Webklex/laravel-imap/blob/master/src/IMAP/Message.php but as I said, quick and dirty.
from laravel-imap.
@RpCoding thanks for your report :) I just released a new version containing the new validation rule.
Ref.: v. 1.0.5.5
from laravel-imap.
Hello, please help me, How can i reply to message from laravel application
from laravel-imap.
Got a new invalid timestamp. :)
Failed to parse time string (22 Jun 18 03:56:36 PM
-05:00 (GMT -05:00)) at position 35 (-): Double timezone specification
from laravel-imap.
I got a new error into datetime:
"DateTime::__construct(): Failed to parse time string (Thu, 8 Nov 2018 08:54:58 -0200 (-02)) at position 31 ((): Unexpected character" -- double espaces into Thu, and 8
Sugestion
switch (true) {
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \(.*)\)+$/i', $date) > 0:
case preg_match('/([A-Z]{2,3}\, \ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ [\-|\+][0-9]{4}\ \(.*)\)+$/i', $date) > 0:
case preg_match('/([0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{2,4}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}\ [A-Z]{2}\ \-[0-9]{2}\:[0-9]{2}\ \([A-Z]{2,3}\ \-[0-9]{2}:[0-9]{2}\))+$/i', $date) > 0:
$date = str_replace(' ', ' ', $date);
$array = explode('(', $date);
$array = array_reverse($array);
$date = trim(array_pop($array));
break;
case preg_match('/([0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
$date .= 'C';
break;
}
from laravel-imap.
@tortato wow you've found a new way to write a date^^ Thanks for the report and a solution. This will be part of the next release :)
Best regards
from laravel-imap.
@Webklex
I got a new error
DateTime::__construct(): Failed to parse time string (Sat, 31 Aug 2013 20:08:23 +0580) at position 30 (0): Unexpected character
from laravel-imap.
'DateTime::__construct(): Failed to parse time string (Mon, 4 Feb 2019 04:03:49 -0300 (-03)) at position 32 ((): Unexpected character
Note: there are 2 spaces between "Mon," and "4"
from laravel-imap.
Hi @tortato @VijayTahkur @archond @anibalealvarezs ,
please update to v. 1.3.0 :)
from laravel-imap.
Hi @Webklex
I caught an exception 'Invalid message date' for the date
Sun, 6 Apr 2008 21:24:33 UT
v 1.4.1
from laravel-imap.
@Webklex
I got a new error
Warning: DateTime::modify(): Failed to parse time string (Wed, 11 Sep 2019 15:23:06 +0600 (+06)) at position 32 ((): Unexpected character
v.1.4.2
from laravel-imap.
@Webklex
I got the following error, could you assist?
DateTime::__construct(): Failed to parse time string (14 Sep 2019 00:10:08 UT +0200) at position 21 (U): The timezone could not be found in the database
from laravel-imap.
Getting the following error:
Failed to parse time string (Tue, 08 Nov 2022 18:47:20 +0000 14:03:33 +0000) at position 32 (1): Double time specification
We are on version 1.6.2. Is this particular date error handled in later versions?
from laravel-imap.
Related Issues (20)
- Serialization Message object with attachments HOT 1
- how to merge multiple email accounts in folder eg inbox HOT 8
- is there away to Connect to Shared Mailbox HOT 2
- Can't move email from folder HOT 4
- Class "Webklex\IMAP\Events\FlagNewEvent" not found HOT 3
- Deleting messages in a thread
- I have facing issue on imap_fetchstructure() please refer the below error and provide the proper solution:
- Does it support Socks5
- I've got error on message delete()
- $message->getTextBody() returns content with headers
- Does it work with gmail?
- Trying to get mailbox from multiple clients
- NO LOGIN, Unable to connect to ssl://localhost:993 (Connection refused) HOT 1
- Error when copying a message.
- get replies for specific message
- Not able to install laravel-imap on laravel11 HOT 2
- Sent folder email not responsed its return blank response
- New Tag ?
- Uncaught ErrorException: Unknown: Must use comma to separate addresses
- IMAP Error: EXPUNGE not allowed in session state when creating folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-imap.