Login   Register  
PHP Classes
elePHPant
Icontem

Mime parser canīt read specific eml file

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      MIME E-mail message parser  >  All threads  >  Mime parser can´t read specific eml file  >  (Un) Subscribe thread alerts  
Subject:Mime parser can´t read specific eml file
Summary:Mime parser canīt read specific eml file
Messages:4
Author:Nelson Silva
Date:2013-06-07 10:49:35
Update:2013-06-08 05:31:11
 

  1. Mime parser can´t read specific eml file   Reply   Report abuse  
Picture of Nelson Silva
Nelson Silva
2013-06-07 10:49:35
Hello,

I developed an php application to read eml files. In that application I'm using Mime Parser class.

This application works good with most of all eml files that I already opened. However, last days I tried open some eml file and my code doesn't work with that eml file.

I will post here header section of the eml that give me problems:

Return-Path: csantos@tecnasol-fge.pt
Received: from arauto.ano.local (LHLO arauto.ano.local) (192.168.10.224) =
by
arauto.ano.local with LMTP; Thu, 6 Jun 2013 11:20:45 +0100 (WEST)
Received: from localhost (localhost [127.0.0.1])
by arauto.ano.local (Postfix) with ESMTP id A11DC6E42F6
for <comercial@ano.pt>; Thu, 6 Jun 2013 11:20:45 +0100 (WEST)
X-Virus-Scanned: amavisd-new at arauto.ano.local
X-Spam-Flag: NO
X-Spam-Score: -1.889
X-Spam-Level:=20
X-Spam-Status: No, score=3D-1.889 tagged_above=3D-10 required=3D6.6
tests=3D[BAYES_00=3D-1.9, HTML_MESSAGE=3D0.001, =
T_OBFU_PDF_ATTACH=3D0.01]
autolearn=3Dham
Received: from arauto.ano.local ([127.0.0.1])
by localhost (arauto.ano.local [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id VV0dRsxjvJc1 for <comercial@ano.pt>;
Thu, 6 Jun 2013 11:20:35 +0100 (WEST)
Received: from mail.edifer.pt (mail.edifer.pt [62.28.11.232])
by arauto.ano.local (Postfix) with ESMTP id CF65F6E42B9
for <comercial@ano.pt>; Thu, 6 Jun 2013 11:20:34 +0100 (WEST)
Received: from eds01ap20.edifer.pt ([192.168.200.52]) by mail.edifer.pt =
with Microsoft SMTPSVC(6.0.3790.3959);
Thu, 6 Jun 2013 11:29:05 +0100
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
Return-Receipt-To: "Santos, Claudia" <csantos@tecnasol-fge.pt>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=3D"----_=3D_NextPart_001_01CE62A0.A769E21D"
Disposition-Notification-To: "Santos, Claudia" <csantos@tecnasol-fge.pt>
Subject: =3D?utf-8?B?QXF1aXNpw6fDo28gZGUgU2Vsb3MgVGVtcG9yYWlz?=3D
Date: Thu, 6 Jun 2013 11:29:00 +0100
Message-ID: =
<B036753237DA4144995B4671C31697D1036DB120@EDS01AP20.edifer.pt>
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:=20
Thread-Topic: =3D?utf-8?B?QXF1aXNpw6fDo28gZGUgU2Vsb3MgVGVtcG9yYWlz?=3D
Thread-Index: AcyTzj6Js3jrB+saTw2dtxxPgmXFDAAAj8BQAADqdpBzswmIsA=3D=3D
From: "Santos, Claudia" <csantos@tecnasol-fge.pt>
To: <comercial@ano.pt>
X-OriginalArrivalTime: 06 Jun 2013 10:29:05.0375 (UTC) =
FILETIME=3D[AB9C26F0:01CE62A0]

In this header section, I realized that have some equals symbols (=) in some lines. I'm new in php and eml files, but maybe is that the problem?

Mime parser class works with RFC822, maybe this eml file has another structure..i donīt know.


  2. Re: Mime parser can´t read specific eml file   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-06-07 11:05:26 - In reply to message 1 from Nelson Silva
The = signs are q-encoding escape characters to encode parts of messages that may be inside others.

If this message was inside another, you better decode the main message as a whole.

  3. Re: Mime parser can´t read specific eml file   Reply   Report abuse  
Picture of Nelson Silva
Nelson Silva
2013-06-07 11:32:38 - In reply to message 2 from Manuel Lemos
Thanks for the fast reply.

Iīm decoding the whole message, like that:

fd = fopen($eml_file, "r") or exit("Não foi possivel abrir o ficheiro ".EML_FILE_NAME);
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

//validar se o eml vem codificado em base64, se sim, vamos descodificar antes de processar.

$emailenc = base64_decode($email);

if($emailenc != FALSE)
{
$email = $emailenc;
}

//#LM1847 END

//create the email parser class
$mime=new mime_parser_class;
$mime->ignore_syntax_errors = 1;

$parameters=array(
'Data'=>$email,
);

$mime->Decode($parameters, $decoded);


//---------------------- GET EMAIL HEADER INFO -----------------------//


//get the name and email of the sender
$fromName = $decoded[0]['ExtractedAddresses']['from:'][0]['name'];

And for this eml is not possible get "From Name"; ['from:']array donīt exists.


Here is what I get when do: var_dump($decoded[0]['ExtractedAddresses']);

array(1) { ["return-path:"]=> array(1) { [0]=> array(1) { ["address"]=> string(23) "csantos@tecnasol-fge.pt" } } }

  4. Re: Mime parser can´t read specific eml file   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-06-08 05:31:11 - In reply to message 3 from Nelson Silva
The question is from where did you get this message file?

It looks like it was removed from a container message because it has some quoted-printable encoding characters in the middle.

In that case, that is not the way to detach the contained message. It should be decoded as a whole inside the container message so the encoded characters in the middle are decoded correctly.