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, <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.