fgets getting muddled line from IMAP connection...
Posted: Tue Sep 28, 2010 1:32 pm
Hi all,
First question on the board, sorry it's so directly to the point!
I'm using an IMAP class I got from phpclasses.org and it seems to work perfectly for 99.99% of emails, the other 0.01% are giving me back a muddled line in the header and or subject and this particular line is of the utmost importance regarding my scripts functionality.
A little background, I'm getting the body and header to each email in a mailbox and parsing them for certain key lines to determine what to do with them, I'm using preg_match to extract the data on the lines that I need and at first I thought it was preg_match that was causing the issue but I've debugged deep down into the bowls of the IMAP class and have come to realise fgets seems to be the route of the issue.
The particular problem I'm having is, in a line in the body and/or header of the message is the text [X-Custom: http://www.website.com/folder/script.php?var=1234] minus the brackets. For 0.01% of emails this is being returned as junk from fgets and I'm getting the following on two lines:
X-Custom: http://www.website.com/folder/script.php?var=3D12=
34
The patterin I see is that I get 3D (hex for = yet the = still remains before it) prepending the code I want after var= and then the 4 digit code is being trasnformed into 12=\r\n34 so my code is being split into two lines. I could write a work around but surely there's an easier option??
Something worth noting is that the line looks perfect in 3 different webmail clients and Thunderbird. Also I'm not specifying a length for fgets and my php version is 5.2.8.
Thanks for any input,
c0ld
First question on the board, sorry it's so directly to the point!
I'm using an IMAP class I got from phpclasses.org and it seems to work perfectly for 99.99% of emails, the other 0.01% are giving me back a muddled line in the header and or subject and this particular line is of the utmost importance regarding my scripts functionality.
A little background, I'm getting the body and header to each email in a mailbox and parsing them for certain key lines to determine what to do with them, I'm using preg_match to extract the data on the lines that I need and at first I thought it was preg_match that was causing the issue but I've debugged deep down into the bowls of the IMAP class and have come to realise fgets seems to be the route of the issue.
The particular problem I'm having is, in a line in the body and/or header of the message is the text [X-Custom: http://www.website.com/folder/script.php?var=1234] minus the brackets. For 0.01% of emails this is being returned as junk from fgets and I'm getting the following on two lines:
X-Custom: http://www.website.com/folder/script.php?var=3D12=
34
The patterin I see is that I get 3D (hex for = yet the = still remains before it) prepending the code I want after var= and then the 4 digit code is being trasnformed into 12=\r\n34 so my code is being split into two lines. I could write a work around but surely there's an easier option??
Something worth noting is that the line looks perfect in 3 different webmail clients and Thunderbird. Also I'm not specifying a length for fgets and my php version is 5.2.8.
Thanks for any input,
c0ld