PHP Classes

The problem with parsing subject

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  The problem with parsing subject  >  (Un) Subscribe thread alerts  
Subject:The problem with parsing subject
Summary:russian subjects
Messages:17
Author:Andrew
Date:2010-10-07 03:51:29
Update:2010-10-08 15:05:32
 
  1 - 10   11 - 17  

  1. The problem with parsing subject   Reply   Report abuse  
Picture of Andrew Andrew - 2010-10-07 03:51:29
Hello,

I have a problem with parsing the subject:
"Subject: Hello Friend," this line is successfully parsed, but
"Subject: =? KOI8-R? Q? = F0 = F2 = C9 = D7 = C5 = D4 = 20 = F3 = CB = D5 = CC-= E8 = C5 = CC = D0 = C5 = D2! = 20 = 3D)? = "(in Russian)

$ Mime-> Analyze ($ decoded [0], $ results);
$ Results ['Subject'] = empty.

What's the problem?

PS Sorry for mistakes, use Google.

  2. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-10-07 05:56:24 - In reply to message 1 from Andrew
PHP variable names are case sensitive. You should use $results['Subject'] instead of $Results['Subject'] .

  3. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Andrew Andrew - 2010-10-07 07:00:49 - In reply to message 2 from Manuel Lemos
Sorry, when I wrote it made a mistake.

My code:
if ($mime->Decode(Array('Data' => $answer), $decoded)) {
if ($mime->Analyze($decoded[0], $results)) {
$msg_subject = $results['Subject'];
}
}

if ($msg_subject != "")
{
$headm = $msg_subject;
}
else
{
$headm = "No subject";
}

if the subject "Subject: Hello Friend" is $ headm = "Hello Friend", but if the subject "Subject: =? KOI8-R? Q? = F0 = F2 = C9 = D7 = C5 = D4 = 20 = F3 = CB = D5 = CC-= E8 = C5 = CC = D0 = C5 = D2! = 20 = 3D)? = "then $ headm =" No subject "

  4. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-10-07 07:58:46 - In reply to message 3 from Andrew
I suspect there is something wrong with your message.

Can you upload the original message complete with headers and body somewhere so I can reproduce the problem?

  5. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Andrew Andrew - 2010-10-07 08:10:59 - In reply to message 4 from Manuel Lemos
No problem.

Here are a few different messages:


Envelope-to: [email protected]
Delivery-date: Wed, 06 Oct 2010 02:24:15 -0500
Received: from web26.pochta.ru ([82.204.219.126]) by rs8.websitehostserver.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from <[email protected]>) id 1P3OMI-0004Kp-RS for [email protected]; Wed, 06 Oct 2010 02:24:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qip.ru; s=dkim; h=MIME-Version:Content-Type:Message-Id:Date:Subject:To:From; bh=u5UYyfAjRhOYhpoxrG2+KkYV+Kk1ZqE6hH8XGlvamCo=; b=FSSXpF4EgxdyXpoACJHr/DIxnGd2Mw6GD4fSpp1LWCJK6jDh7xDkpxeUUsL69kNoHdCv63kuhQHe1EJ43fQXwnWnF7LkAosXNIBc+4kVezsuQagTGuTWxoAXHvwZUvx0;
Received: from [127.0.0.1] (port=49283 helo=localhost) by web26.pochta.ru ( sendmail 8.13.3/8.13.1) with esmtp id 1P3OMD-0007NY-IH for [email protected]; Wed, 06 Oct 2010 11:24:09 +0400
From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA=20=EE=C5=C4=CF=C2=D9=CC=D8=D3=CB=C9=CA?= <[email protected]>
To: [email protected]
Subject: =?KOI8-R?Q?=F0=F2=C9=D7=C5=D4=20=F3=CB=D5=CC-=E8=C5=CC=D0=C5=D2!=20=3D)?=
Date: Wed, 06 Oct 2010 11:24:09 +0400
Message-Id: <[email protected]>
X-Priority: 3
Content-Type: multipart/alternative; charset="KOI8-R"; boundary="=_f6447dfdee5bf1bb956b6190e377b11b"

MIME-Version: 1.0
X-NoSpam-Exim-Host: 82.204.219.87
X-NoSpam-Exim-Port: 8092
X-QIP-Mass: No
X-NoSpam-Exim-Scanned: Yes
X-NoSpam-Exim-Result: OK

Hello

and second:


Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Wed, 06 Oct 2010 02:39:23 -0500
Received: from [109.110.37.85] (helo=[192.168.1.2]) by rs8.websitehostserver.net with esmtp (Exim 4.69) (envelope-from <[email protected]>) id 1P3Oaw-00009I-K8 for [email protected]; Wed, 06 Oct 2010 02:39:23 -0500
Subject: =?koi8-r?Q?=CF=CC=CF=CC=CF?=
From: school <[email protected]>
Reply-To: [email protected]
To: [email protected]
Content-Type: multipart/mixed; boundary="=-Zh3StWGIZhR6M6q/8Kag"
Date: Wed, 06 Oct 2010 18:39:18 +1100
Message-ID: <1286350758.12205.6.camel@administrator-desktop>

Mime-Version: 1.0
X-Mailer: Evolution 2.28.3

Test123


  6. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-10-07 08:21:39 - In reply to message 5 from Andrew
These messages are crippled. Please save the original complete messages and upload them somewhere as if they are binary, instead of pasting them here.

  7. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Andrew Andrew - 2010-10-07 08:42:25 - In reply to message 6 from Manuel Lemos

Here is an example of saved messages:

school-helper.ru/errormessage.eml

  8. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-10-07 08:49:14 - In reply to message 7 from Andrew
I tried that message here and it parses correctly. The $results['Subject'] contains a string using koi8-r character set. If you want to display it in an HTML page, you may need to set the character set of the page to koi8-r and eventually use HtmlSpecialChars() to escape < , > and & .

  9. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Andrew Andrew - 2010-10-07 09:07:31 - In reply to message 8 from Manuel Lemos
For parsing and should indicate the entire message or only header?
I'm parsing only header.

  10. Re: The problem with parsing subject   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-10-07 09:49:12 - In reply to message 9 from Andrew
You should pass the whole message to the class but you can use the SkipBody flag in the Decode function so it does not waste time decoding the whole body, since you only want the subject.

 
  1 - 10   11 - 17