PHP Classes

Breaking spaces

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Breaking spaces  >  (Un) Subscribe thread alerts  
Subject:Breaking spaces
Summary:E-mail parsing
Messages:5
Author:Matt Robertson
Date:2008-10-07 22:30:46
Update:2008-10-25 00:55:40
 

  1. Breaking spaces   Reply   Report abuse  
Picture of Matt Robertson Matt Robertson - 2008-10-07 22:30:46
First, thanks for the great class.

I run into problems with spaces in the original e-mail being changed into a newline character. I am trying to reverse the process to restore the original text. Is this a charset encoding problem? Has anyone else ran into this issue?

  2. Re: Breaking spaces   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-10-07 23:58:30 - In reply to message 1 from Matt Robertson
I am not sure what you mean. Can you give an example script and sample message that exhibits the problem?

  3. Re: Breaking spaces   Reply   Report abuse  
Picture of Matt Robertson Matt Robertson - 2008-10-24 00:07:35 - In reply to message 2 from Manuel Lemos
Here is a good example, You will see the last part of the line "- CX" gets changed into "-[line feed]CX" So the space was replaced with a line feed.
Here is the original e-mail in the e-mail editor: Outlook 2003

approved
_____________________________________________
From: Winowich, Kurt
Sent: Thursday, October 23, 2008 3:05 PM
To: '[email protected]'
Subject: Approve: Holcomb - CX


"\\corpusfs16\CMMRCLMASOEAST\SA Review\MidAtlantic\Clariion\Holcomb - CX"

Approve:





here is the raw e-mail how exim passed it to my program:

From: [email protected]
Received: from CORPUSMX60C.corp.domain.com ([]) by corpussmtp3.corp.domain.com with Microsoft SMTPSVC(6.0.3790.1830);
Thu, 23 Oct 2008 15:07:13 -0400
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Subject: FW: Approve: Holcomb - CX
Date: Thu, 23 Oct 2008 15:07:11 -0400
Message-ID: <CCBE80B1DA4ABB4CB1BBD0097C49E296037328AA@CORPUSMX60C.corp.domain.com>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Topic: Approve: Holcomb - CX
Thread-Index: Ack1Qksq7kZ9OEUXSbm4FluWb0C87QAAAUwAAAALYZA=
To: <[email protected]>
X-OriginalArrivalTime: 23 Oct 2008 19:07:13.0199 (UTC) FILETIME=[8E8563F0:01C93542]
X-RSA-Inspected: yes
X-RSA-Classifications:
X-RSA-Action: allow
X-Spam-Status: No, score=-5.9
X-Spam-Score: -58
X-Spam-Bar: -----
X-Spam-Flag: NO

approved
_____________________________________________
From: Winowich, Kurt=20
Sent: Thursday, October 23, 2008 3:05 PM
To: '[email protected]'
Subject: Approve: Holcomb - CX


"\\corpusfs16\CMMRCLMASOEAST\SA Review\MidAtlantic\Clariion\Holcomb -
CX"

Approve:

  4. Re: Breaking spaces   Reply   Report abuse  
Picture of Matt Robertson Matt Robertson - 2008-10-24 00:13:48 - In reply to message 3 from Matt Robertson
the thing is that when Outlook receives this e-mail it displays the e-mail correctly. So outlook is able to reverse the process. I found that if a line is over 72 characters and it contains a space, the last space in the line will be changed to a linefeed. I wrote a loop to try and fix the problem but it has to possibility of catching false positives. Here is the script:

$lines = explode("\n",$message);

for($i=0;$i<count($lines)-1;$i++) {
$next_line = explode(" ",$lines[$i+1]);
$count = strlen($lines[$i]);

if( $count < 73 && ($count + strlen($next_line[0])) > 71) {
$message_fixed .= $lines[$i] . ' ' . $lines[$i+1];
$i++;
}
else {
$message_fixed .= $lines[$i] . "\n";
}
}
if($i < count($lines) ) {
$message_fixed .= $lines[$i];
}

  5. Re: Breaking spaces   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-10-25 00:55:40 - In reply to message 3 from Matt Robertson
I think you need to upload the example file somewhere because pasting it here may change the real message format.