PHP Classes

Apple Content-Transfer-Encoding: quoted-printable

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Apple Content-Transfer-Encoding:...  >  (Un) Subscribe thread alerts  
Subject:Apple Content-Transfer-Encoding:...
Summary:Apple Content-Transfer-Encoding: quoted-printable
Messages:4
Author:PRIVATE
Date:2024-03-10 22:32:10
 

  1. Apple Content-Transfer-Encoding:...   Reply   Report abuse  
Picture of PRIVATE PRIVATE - 2024-03-10 22:32:10
Hi we have an issue with emails that are sent from Apple clients using Content-Transfer-Encoding: quoted-printable.

Do you have any examples of how to parse these types of emails,

  2. Re: Apple Content-Transfer-Encoding:...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2024-03-11 06:43:26 - In reply to message 1 from PRIVATE
Hello,

The parser class should be able to parse all types of MIME messages that comply with the standards.

Can you explain better the issue and provide a sample message so I can try to reproduce the issue?

  3. Re: Apple Content-Transfer-Encoding:...   Reply   Report abuse  
Picture of PRIVATE PRIVATE - 2024-03-11 12:58:11 - In reply to message 2 from Manuel Lemos
Thank you for the quick reply. We have the following code where $email is the contents of php://stdin

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

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


if(substr($decoded[0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Body'])){
$body = $decoded[0]['Body'];
} elseif(substr($decoded[0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Body'])) {
$body = $decoded[0]['Parts'][0]['Body'];
} elseif(substr($decoded[0]['Parts'][0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Parts'][0]['Body'])) {
$body = $decoded[0]['Parts'][0]['Parts'][0]['Body'];
}

Obviously this is only allowing for plain text but we cannot find example of how to parse other types.

We received an email yesterday with the following:


Content-Type: multipart/alternative; boundary=Apple-Mail-B8AEEF88-4B27-4133-814E-4502D46715BA
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)

With content like:


Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto">Hi,&nbsp;<div>

Our body was obviously empty after parsing using the above code and we are unsure on how to have a solution that will parse all types.

  4. Re: Apple Content-Transfer-Encoding:...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2024-03-13 03:46:58 - In reply to message 3 from PRIVATE
Hello,

The package automatically decodes MIME messages of type quoted-printable.

I saved a file with a test message with the content below:

Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto">Hi,&nbsp;<div>

Then I used the test_message_decoder.php with PHP from the command line passing the name of the file that I saved above as parameter and it outputted this result below:

array(6) {
["Headers"]=>
array(2) {
["content-type:"]=>
string(24) "text/html; charset=utf-8"
["content-transfer-encoding:"]=>
string(16) "quoted-printable"
}
["Parts"]=>
array(0) {
}
["Position"]=>
int(0)
["Body"]=>
string(118) "<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi,&nbsp;<div>
"
["BodyPart"]=>
int(1)
["BodyLength"]=>
int(118)
}
array(4) {
["Type"]=>
string(4) "html"
["Description"]=>
string(12) "HTML message"
["Encoding"]=>
string(5) "utf-8"
["Data"]=>
string(118) "<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi,&nbsp;<div>
"
}

Can you try doing this and let me know if you get the same result?