PHP Classes

Parsing Multipart messages

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Parsing Multipart messages  >  (Un) Subscribe thread alerts  
Subject:Parsing Multipart messages
Summary:Parsing of Multipart messages with no 'Content-Type' field
Messages:12
Author:shailesh
Date:2007-06-17 14:25:09
Update:2007-06-25 09:08:41
 
  1 - 10   11 - 12  

  1. Parsing Multipart messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-17 14:25:09
Hi Lemos,
Firstly I thank you for providing the Mime Email parser as a php class. I have started using the same for my LAMP application just a few days back and also I am newbie to PHP as such. So thats great work by you.

I have a problem with parser though, I observe that the mails I get from few web based services like gmail and hotmail DONOT have the
'Content-Type' field in the header for 'multipart/realted' and no 'boundary' specified in the header too.
But the message is indeed multipart and is separated by valid boundaries. On

On using the class for these messages , the Body output I get include the boundaries and the text and html togther. I hope I am clear on thFrom:

For message like this ------------------>>

Shailesh Shirali <[email protected]>
Subject: IGNORE : Test subject 4

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Test 1111111111111Test 222222222222222Test 333333333333333
_________________________________________________________________
Sign in and get updated with all the action!
content.msn.co.in/Sports/FormulaOne ...

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style=3D"text-align: left;">Test 1111111111111<br>Test 222222222=
222222<br>Test 333333333333333<br></div><br /><hr />Sign in and get updated=
with all the action! <a href=3D'http://content.msn.co.in/Sports/FormulaOne=
/Default' target=3D'_new'>Formula One</a></body>
</html>=

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_--


I get this as the Body in the output Array --------->


--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Test 1111111111111Test 222222222222222Test 333333333333333
_________________________________________________________________
Sign in and get updated with all the action!
content.msn.co.in/Sports/FormulaOne ...

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Do you have fix for this. You inputs will be really helpful

Thanks & Regards
Shailesh

  2. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-06-17 21:30:55 - In reply to message 1 from shailesh
I would need to see the whole message to understand exactly what kind of message you are seeing. Please try saving the whole message to an .eml file and upload it somewhere so I can examine it.

  3. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-18 05:06:05 - In reply to message 2 from Manuel Lemos
Hi Manuel,
I have emailed to you 2 eml files which I recieved from my hotmail and gmail accounts. These messages come without 'Content-Type' in the header.

I hoping that you can suggest me a quick fix on this as it will take me a long time to decipher the php code and find my own fix.

Your interest in the problem is truly appreciated.

Thanks & Regards
Shailesh

  4. Here is one of the messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-19 06:42:07 - In reply to message 3 from shailesh
From: Tom Harry <[email protected]>
Subject: IGNORE : Test subject 4

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Test 1111111111111Test 222222222222222Test 333333333333333
_________________________________________________________________
Sign in and get updated with all the action!
content.msn.co.in/Sports/FormulaOne ...

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style=3D"text-align: left;">Test 1111111111111<br>Test 222222222=
222222<br>Test 333333333333333<br></div><br /><hr />Sign in and get updated=
with all the action! <a href=3D'http://content.msn.co.in/Sports/FormulaOne=
/Default' target=3D'_new'>Formula One</a></body>
</html>=

--_de28b48f-27f5-4a5b-ae01-ab219cbc5471_--

  5. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-06-19 21:38:17 - In reply to message 3 from shailesh
Those messages are odd. They do not comply with RFC standards. Does Gmail and Hotmail show them as HTML messages?

  6. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-20 04:49:37 - In reply to message 5 from Manuel Lemos
Hi Manuel,

Yes they are not complying with RFC standard but it seems fine at Gmail and hotmail.
Also other mail clients like MS-Outlook ,Evolution etc seem to understand these messages,so I thought this should be accomodated in the class although not a standard.

Thanks & Regards
Shailesh


  7. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-06-20 21:35:21 - In reply to message 6 from shailesh
No, these messages do not open correctly in Thunderbird.

I suspect that Gmail and Hotmail are not showing you all headers but Content-type was sent in the original messages.

What program is sending these messages?

Please use the same program and send the message again to mlemos at gmail.com and manuelallemos at hotmail.com so I can verify what exactly arrives there.

  8. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-22 11:29:59 - In reply to message 7 from Manuel Lemos
Good-day Manuel,
I am picking-up these messages directly from my mail-servers folder. I believe that our mail-server would not do any Mime striping, also verified this from my mail-administrator. So as such these mails are not from any mail-client or program.
I also made in a fix in mime_parser.php to accomodate for these
kind of mesages, Seems to be fine with both kinds of messages RFC compliant and and non-compliant. I will be mailing you the code the following Monday (my monday).

Thanks
Shailesh P Shirali
Bangalore India



  9. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-06-22 22:41:56 - In reply to message 8 from shailesh
I don't think it is good idea to parse invalid messages, as if they were valid.

Also I am not convinced that the messages are really sent that badly formed and Gmail and Hotmail show them correctly.

You did not tell me what system sends such messages.

Can you send a message like that to mlemos at gmail.com so I can see exactly what arrives?

  10. Re: Parsing Multipart messages   Reply   Report abuse  
Picture of shailesh shailesh - 2007-06-25 05:59:53 - In reply to message 9 from Manuel Lemos
HI Manuel,
Yes you are right that these are non-compliant messages but the source in none other than GMAIL and HOTMAIL mail server. If you send a mail from either your GMAIL or HOTMAIL account to your local mail account and capture the message at your local mail-server and not your mail-client , you are likely to see such messages. Our mail-server (system) is a linux server.

The problem is in GMAIL and HOTMAIL which send non-compliant messages.Hope this is clear for you now.

Thanks & Regards
Shailesh





 
  1 - 10   11 - 12