PHP Classes

Problems with google Mail

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Problems with google Mail  >  (Un) Subscribe thread alerts  
Subject:Problems with google Mail
Summary:Googlemail Mail Headers are not decoded correctly
Messages:6
Author:Tom
Date:2008-06-20 18:12:20
Update:2008-06-22 19:48:27
 

  1. Problems with google Mail   Reply   Report abuse  
Picture of Tom Tom - 2008-06-20 18:12:20
Hi Manuel,

i post here a googlemail raw message. Look at the Subject Line. These line have some spezial characters where lost in DecodedHeaders like:

["DecodedHeaders"]=>
array(1) {
["subject:"]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(2) {
["Value"]=>
string(21) "asdas dasd asdasd"
["Encoding"]=>
string(10) "ISO-8859-1"
}
}
}
}

Ist this an error in the class?
Greetings, Tom

---------raw mail begin-----------

Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.236])
by h942110.serverkompetenz.net (Postfix) with ESMTP id B42EEE3765D
for <[email protected]>; Fri, 20 Jun 2008 19:07:48 +0200 (CEST)
Received: by wr-out-0506.google.com with SMTP id 50so1026821wra.13
for <[email protected]>; Fri, 20 Jun 2008 10:07:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=gamma;
h=domainkey-signature:received:received:message-id:date:from:to
:subject:mime-version:content-type;
bh=X/PDQ5dUsoZNXrwJ5705pamNtlnVY0D6fBMS31ois4w=;
b=N5Wt4Lnsj91p2fg0UBwOTslapu0XZa09hApm0yqe+FUg48z2kn0dXTI8bwVi0uPRaK
aYSntTCPjwSYfX6KsgxRmF0fInTgchbioHS1rcjlXdtwzWaNm6lXfazAISULAQ1JCb9n
kYOwILBBdaI/biwu5Oo+AX1EoNZ+WetUHjOr0=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=googlemail.com; s=gamma;
h=message-id:date:from:to:subject:mime-version:content-type;
b=Z0itPHgt0y3tjtTfPsZH0+W+RB+saTtXGQ3PC25DVv8poi+10EJuyEZbfbGahxMmIw
0WEdrBlua4nhOUl7YZgrixYrxPQ5VovuShPQPCk6LlDbvcJz8BsExsHNLHf1HvJ8xDie
biLs1auD0dWzJ3tsFe+cmUdB/6ZVRMiImIwjE=
Received: by 10.90.74.7 with SMTP id w7mr4837154aga.111.1213981658101;
Fri, 20 Jun 2008 10:07:38 -0700 (PDT)
Received: by 10.90.66.15 with HTTP; Fri, 20 Jun 2008 10:07:38 -0700 (PDT)
Message-ID: <[email protected]>
Date: Fri, 20 Jun 2008 19:07:38 +0200
From: "tom tom" <[email protected]>
To: [email protected]
Subject: =?ISO-8859-1?Q?asdas_dasd=F6=E4=F6=FC=DFasdasd?=
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_14996_12677338.1213981658087"

------=_Part_14996_12677338.1213981658087
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

asdasd asd asd asd=F6=E4as=F6d=FCasd

------=_Part_14996_12677338.1213981658087
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

asdasd asd asd asd=F6=E4as=F6d=FCasd

------=_Part_14996_12677338.1213981658087--
---------raw mail end-----------



  2. Re: Problems with google Mail   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-20 18:47:47 - In reply to message 1 from Tom
I just tried it myself and it works as expected.

Couldn't you be displaying that on a browser or terminal that does not display characters with unsupported codes?

Notice that the subject string has 21 bytes and you only pasted 17.

  3. Re: Problems with google Mail   Reply   Report abuse  
Picture of Tom Tom - 2008-06-20 19:23:30 - In reply to message 2 from Manuel Lemos
No, the lost 4 Bytes are lost decoding process. But now i can't repoduce it.

I have some other trouble with googlemails. My function where gets the parts don't get the google body message. I'm searching the bug in my routine.

But i have another question:

Not any decoded message (from different Clients send) have a [DecodedHeaders]. Why ?

Thany for fast responds Manuel.

Greeting, Tom

  4. Re: Problems with google Mail   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-20 19:42:56 - In reply to message 3 from Tom
No you are probably trying to see the var_dump result in a browser that uses UTF-8 to show the subject but the bytes are in ISO-8859-1. Try using Header('Content-Type: plain/text; charset=iso-8859-1'); before the var_dump and the characters will appear correctly in the browser.

As for the DecodedHeaders, that array only returns that were originally encoded. The other header values you may obtain from the Headers array.

  5. Re: Problems with google Mail   Reply   Report abuse  
Picture of Tom Tom - 2008-06-20 20:30:37 - In reply to message 4 from Manuel Lemos
Ok, i understand you. My Bug in getparts are fixed and googlemail are no problem now.

But one thing i don't understand:

This is a dump from $decoded[$message]['DecodedHeaders']:


array(1) {
["subject:"]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(2) {
["Value"]=>
string(25) "Glühbirne hat ausgedient"
["Encoding"]=>
string(5) "UTF-8"
}
}
}
}

To get the decoded subject content i need:

echo $decoded[$message]['DecodedHeaders']['subject:'][0][0]['Value'];

Question: Why are there "[0][0]" Arrays in output. I don't see the reason.

  6. Re: Problems with google Mail   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-22 19:48:27 - In reply to message 5 from Tom
Although it is not usual, the Internet mail standards allow for mixing text sections with different character sets in headers. So, the class returns each text section individually with the text and the associated character set.