| Recommend this page to a friend! |
| PHP MIME Email Message Parser | > | All threads | > | Not able to read utf-8 message | > | (Un) Subscribe thread alerts |
| |||||||||||||||
Hi,
Thanks for the script and actively maintaining it with good support. I tried your class with a utf-8 message, but it is failing. Please find the attached message. ======================================= Fromx: [email protected] Oct 07 19:08:48 2008 Return-Path: <useremail@...> X-Sender: useremail@... X-Apparently-To: [email protected] X-Received: (qmail 55170 invoked from network); 8 Oct 2008 02:08:46 -0000 X-Received: from unknown (66.218.67.96) by m57.grp.scd.yahoo.com with QMQP; 8 Oct 2008 02:08:46 -0000 X-Received: from unknown (HELO ti-out-0910.google.com) (209.85.142.188) by mta17.grp.scd.yahoo.com with SMTP; 8 Oct 2008 02:08:46 -0000 X-Received: by ti-out-0910.google.com with SMTP id j3so1985354tid.8 for <[email protected]>; Tue, 07 Oct 2008 19:08:45 -0700 (PDT) X-Received: by 10.110.49.2 with SMTP id w2mr1212417tiw.56.1223431725635; Tue, 07 Oct 2008 19:08:45 -0700 (PDT) X-Received: by 10.110.105.1 with HTTP; Tue, 7 Oct 2008 19:08:45 -0700 (PDT) Message-ID: <96ab1a490810071908r2f544e6fh2661d0969e5f06a1@...> Date: Wed, 8 Oct 2008 10:08:45 +0800 To: [email protected] In-Reply-To: <96ef192be15ad1dd961b8b8e05141603@...> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Content-Disposition: inline References: <96ef192be15ad1dd961b8b8e05141603@...> X-Google-Sender-Auth: 04ed20463299c011 X-Originating-IP: 209.85.142.188 X-eGroups-Msg-Info: 1:12:0:0:0 X-eGroups-From: "user" <user@...> From: "user" <user@...> Subject: =?UTF-8?Q?Will_anybody_throw_a_beautiful_harp_o?= =?UTF-8?Q?ut_on_the_street_|=E0=AE=A8?= =?UTF-8?Q?=E0=AE=B2=E0=AF=8D=E0=AE=B2=E0=AE=A4?= =?UTF-8?Q?=E0=AF=8B=E0=AE=B0=E0=AF=8D_=E0=AE=B5?= =?UTF-8?Q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OCvgeCuqOCvjeCupCDgrprgr4vgrrQg4K614K+G4K6j4K+N4K6V4K6yIOCumuCuv+CusuCv iOCur+CviCDgrqrgrrHgr43grrHgrr/grq8g4K6u4K6f4K6y4K+B4K6V4K+N4K6V4K+BCuCu quCusuCusOCvgeCuruCvjSDgrq7grrHgr4Hgrq7gr4rgrrTgrr8g4K6V4K+C4K6x4K+B4K6V 4K+I4K6v4K6/4K6y4K+NLCDgrofgrqjgr43grqQg4K6a4K6/4K6y4K+IIOCuheCumeCvjeCu leCvhyDgro7grqrgr43grqrgrp/grr8g4K614K6o4K+N4K6k4K6k4K+BIOCujuCuqeCvjeCu sQrgrpXgr4fgrp/gr43grp/grr7grrDgr43grpXgrrPgr40uIOCuquCusiDgroXgrq7gr4bg rrDgrr/grpXgr43grpUsIOCukOCusOCvi+CuquCvjeCuquCuv+CuryDgroXgrrDgr4Hgrpng r43grpXgrr7grp/gr43grprgrr/grq/grpXgrpngr43grpXgrrPgrr/grrLgr40g4K6a4K+L 4K604K6w4K+NIOCuleCuvuCusgrgrrXgr4bgrqPgr43grpXgrrIg4K6a4K6/4K6y4K+I4K6V 4K6z4K+NIOCuieCus+CvjeCus+CuqS4KCmh0dHA6Ly93d3cucG9ldHJ5aW5zdG9uZS5pbi9s YW5nL3RhLzIwMDgvMTAvMDgvd2lsbC1hbnlib2R5LXRocm93LWEtYmVhdXRpZnVsLWhhcnAt b3V0LW9uLXRoZS1zdHJlZXQuaHRtbAoKQmVzdCByZWdhcmRzLApWaWpheQp2ai5lcGlzdGVt ZUBwb2V0cnlpbnN0b25lLmluCi0tIApodHRwOi8vd3d3LnBvZXRyeWluc3RvbmUuaW4KSGVy ZSB0aGUgbGFuZ3VhZ2Ugb2Ygc3RvbmUgc3VycGFzc2VzIHRoZSBsYW5ndWFnZSBvZiBtYW4K ==============================
I was able to parse the message without problems. What is failing for you?
sorry, I should have pasted the output.
MIME message decoding successful. 1 message was found. Message 1: array(6) { ["Headers"]=> array(27) { ["from "]=> string(46) "[email protected] Tue Oct 07 19:08:48 2008" ["return-path:"]=> string(23) "<[email protected]>" ["x-sender:"]=> string(21) "[email protected]" ["x-apparently-to:"]=> string(30) "[email protected]" ["x-received:"]=> array(4) { [0]=> string(55) "(qmail 55170 invoked from network); 8 Oct 2008 02:08:46" [1]=> string(59) "from unknown (HELO ti-out-0910.google.com) (209.85.142.188)" [2]=> string(55) "by ti-out-0910.google.com with SMTP id j3so1985354tid.8" [3]=> string(57) "by 10.110.105.1 with HTTP; Tue, 7 Oct 2008 19:08:45 -0700" } ["-0000 x-received:"]=> string(27) "from unknown (66.218.67.96)" ["by "]=> array(2) { [0]=> string(58) "m57.grp.scd.yahoo.com with QMQP; 8 Oct 2008 02:08:46 -0000" [1]=> string(60) "mta17.grp.scd.yahoo.com with SMTP; 8 Oct 2008 02:08:46 -0000" } ["for "]=> string(65) "<[email protected]>; Tue, 07 Oct 2008 19:08:45 -0700" ["(pdt) x-received:"]=> string(60) "by 10.110.49.2 with SMTP id w2mr1212417tiw.56.1223431725635;" ["tue, "]=> string(32) "07 Oct 2008 19:08:45 -0700 (PDT)" ["(pdt) message-id:"]=> string(0) "" ["<[email protected]> date:"]=> string(30) "Wed, 8 Oct 2008 10:08:45 +0800" ["to:"]=> string(30) "[email protected]" ["in-reply-to:"]=> string(55) "<[email protected]>" ["mime-version:"]=> string(3) "1.0" ["content-type:"]=> string(25) "text/plain; charset=UTF-8" ["content-transfer-encoding:"]=> string(6) "base64" ["content-disposition:"]=> string(6) "inline" ["references:"]=> string(55) "<[email protected]>" ["x-google-sender-auth:"]=> string(16) "04ed20463299c011" ["x-originating-ip:"]=> string(14) "209.85.142.188" ["x-egroups-msg-info:"]=> string(10) "1:12:0:0:0" ["x-egroups-from:"]=> string(41) ""vj kumar" <[email protected]>" ["from:"]=> string(34) ""vj kumar" <[email protected]>" ["subject:"]=> string(49) "=?UTF-8?Q?Will_anybody_throw_a_beautiful_harp_o?=" ["=?utf-8?q?ut_on_the_street_|=e0=ae=a8?= =?utf-8?q?=e0=ae=b2=e0=af=8d=e0=ae=b2=e0=ae=a4?= =?utf-8?q?=e0=af=8b=e0=ae=b0=e0=af=8d_=e0=ae=b5?= =?utf-8?q?=e0=af=80=e0=ae=a3=e0=af=88_=e0=ae=9a?= =?utf-8?q?=e0=af=86=e0=ae=af=e0=af=8d=e0=ae=a4=e0=af=81?= x-yahoo-group-post:"]=> string(20) "member; u=332924112;" ["y=_ecl9v2i_cpowb1cjdwrjr2gfuwxbqtdrppk3e-cf9gxxcqrptw x-yahoo-profile:"]=> string(11) "vj_episteme" } ["Parts"]=> array(0) { } ["DecodedHeaders"]=> array(1) { ["subject:"]=> array(1) { [0]=> array(1) { [0]=> array(2) { ["Value"]=> string(37) "Will anybody throw a beautiful harp o" ["Encoding"]=> string(5) "UTF-8" } } } } ["BodyPart"]=> int(1) ["BodyLength"]=> int(1404) ["ExtractedAddresses"]=> array(3) { ["return-path:"]=> array(1) { [0]=> array(1) { ["address"]=> string(21) "[email protected]" } } ["to:"]=> array(1) { [0]=> array(1) { ["address"]=> string(30) "[email protected]" } } ["from:"]=> array(1) { [0]=> array(2) { ["address"]=> string(21) "[email protected]" ["name"]=> string(8) "vj kumar" } } } } array(9) { ["Type"]=> string(4) "text" ["Description"]=> string(12) "Text message" ["Encoding"]=> string(5) "utf-8" ["Subject"]=> string(37) "Will anybody throw a beautiful harp o" ["SubjectEncoding"]=> string(5) "utf-8" ["From"]=> array(1) { [0]=> array(2) { ["address"]=> string(21) "[email protected]" ["name"]=> string(8) "vj kumar" } } ["To"]=> array(1) { [0]=> array(1) { ["address"]=> string(30) "[email protected]" } } ["Return-path"]=> array(1) { [0]=> array(1) { ["address"]=> string(21) "[email protected]" } } ["DataLength"]=> int(1404) } Warning: invalid header name line at position 283 Warning: invalid header name line at position 417 Warning: invalid header name line at position 549 Warning: invalid header name line at position 698 If you see, the subject is not getting the utf-8 characters
In other words, I want to retireve the subject with utf-8 encoded. expected result is "Will anybody throw a beautiful harp out on the street |நல்லதோர்
வீணை செய்து" which I am not getting. Hope this is wrong place to ask this question.
You just need to pick the value of the Subject entry of the array returned by the Analyze function.
What happens is that you are displaying the results of the var_dump() function in an HTML page. The browser processes the HTML entities that you have there like ந and they are not rendered as visible characters, but they are there in the page. So everything is working as expected.
cool. Thanks a lot, appreciate it
|
info at phpclasses dot org.
