PHP Classes

Manuel Lemos Mime parser issue

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Manuel Lemos Mime parser issue  
Subject:Manuel Lemos Mime parser issue
Summary:Parser loses message inside gmail old thread html
Messages:2
Author:Paul Claridge
Date:2025-12-20 11:03:44
Update:2025-12-21 03:43:27
 

  1. Manuel Lemos Mime parser issue   Reply   Report abuse  
Picture of Paul Claridge Paul Claridge - 2025-12-21 03:43:27
Been using this for years and doing a bit of testing came across this issue which some kind person might be able to guide me on please?

The message content (part) as follows:

--000000000000d8482f064652c3dd
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">lets try this then</div><br><div class=3D"gmail_quote gmai=
l_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, 19 Dec 202=
5 at 17:31, Paul Claridge &lt;<a href=3D"mailto:[email protected]">=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20=
4,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr">Lets try without=
baggage</div><br><div class=3D"gmail_quote"><br></div></div>
</blockquote></div>

--000000000000d8482f064652c3dd--

The actual message was "lets try this then"

If I debug the code like this:
if (!$mime->Decode($parameters, $decoded)) {
// log errors for investigation
$msg .= 'MIME message decoding error: '.$mime->error.' at position '.$mime->error_position;
if ($mime->track_lines && $mime->GetPositionLine($mime->error_position, $line, $column)) {
$msg .= ' line '.$line.' column '.$column;
}
$msg .= "\n";
$errs++;
} else {
error_log(print_r($decoded,true),3,"/psc/mail");
$msg .= (count($decoded)==1 ? '1 message was found.' : count($decoded).' messages were found.')."\n";
for ($message = 0; $message < count($decoded); $message++) {
error_log(print_r($decoded[$message],true),3,"/psc/mail");
if ($mime->Analyze($decoded[$message], $results)) {
error_log(print_r($results,true),3,"/psc/mail");
$this->redirect_email($results);
} else {
$msg .= 'MIME message analyse error: '.$mime->error."\n";
$errs++;
}
}

I see stuff like this:

Array
(
[Type] => html
[Description] => HTML message
[Encoding] => utf-8
[DataFile] => /var/www/html/gnb/ci460/public/uploads/sI7QY8r9/2
[Alternative] => Array
(
[0] => Array
(
[Type] => text
[Description] => Text message
[Encoding] => utf-8
[DataFile] => /var/www/html/gnb/ci460/public/uploads/sI7QY8r9/1
)

)

[Subject] => Re: Making contact (GNBC-1766164018-12)
[Date] => Fri, 19 Dec 2025 19:37:04 +0000
[From] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Paul Claridge
)

)

[To] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Good News BIG Team
)

)

)
Array
(
[0] => Array
(
[Headers] => Array
(
[from ] => [email protected] Fri Dec 19 19:53:51 2025
[received:] => Array
(
[0] => from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41]) by ikserver2.goodnewsbig.com (8.15.2/8.15.2/Debian-18) with ESMTP id 5BJJroWE063949 for <[email protected]>; Fri, 19 Dec 2025 19:53:51 GMT
[1] => by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-6446c924f9eso2027587d50.1 for <[email protected]>; Fri, 19 Dec 2025 11:53:51 -0800 (PST)
)

[authentication-results:] => ikserver2.goodnewsbig.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com [email protected] header.a=rsa-sha256 header.s=20230601 header.b=gc35Gv8E; dkim-atps=neutral
[dkim-signature:] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766174030; x=1766778830; darn=goodnewsbig.com; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=bifDuUndUAuQRjcvn7+MEfVPfiMqD5tyAwtjf3wba7Y=; b=gc35Gv8EhIyvPCqHZi2NKuh+Zfqetj+AehVQTDkhHjHzqZgfxq9ONvjcT1++BOdtdU T+gBFdRhfygL2o38bSVu6R4e6nvm3d83JdFRHz77+drvZD4h3COahfPO9Stislsa9pXp TqkeU5hhABSvh4FX2xhJ/XpzvLH03oB46s7d9/DqJ98ueMAsi2pNKX8XTrF9ketmwEo2 Hre2bACZVPzfcatgvi+2sO9G3hJdK9TYsUtN0nacnVwC/QBhk0L/ZZCZHHpyDxShlXHn hYO9f1KTPuKTXAvmG/jQoV+v4dz58tvfpLwxboZuXMrtocUhjHoWAt6pXGD54fDZAQM+ ZXVw==
[x-google-dkim-signature:] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766174030; x=1766778830; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bifDuUndUAuQRjcvn7+MEfVPfiMqD5tyAwtjf3wba7Y=; b=G8sg8XsEL0fYuZ94oBqwq9BE8whLRuFnje7malEGtj8jab2gT931ah9ohVkP9dAot5 vw5ymYPOp7ItMFd0y2dGgHVAzLyIJBe5PVKJNC99ypY/GBrvUwArLeLiNAelnF/p1wGe A7StxdaSYTVmcSMUCOUPoXXdahs8OkU3Dyn5YOWBSIYFt8MwEmEo5aJPOjiyMcqEdNc/ 9ApWk46xypP+PLMQxLbhieBPIa503ZAZRPmnhLUueTbsRDYqo6DrgzkH9zkLj7p4XGRs WJAeritX/ZCZDX13emu3MJ86Ni3uLwdt+ceV3YlpVsIGxq1hQpwwO8AjipZSJTPdYM9z JYxQ==
[x-gm-message-state:] => AOJu0YzuQjckpIC1gvCqc0c8UIgLQ1sHADpTNE6qt8GGAOwY/tdm/BRE Gos48d1pLkMZynsgCKOP/N1VekbZoLloeFIRkMiFaPZoBlb8w+YDcXYK7bttAme5I55/Nj/lW4e tOLmzIC9NednMqHhyBjjLC8JDKkEGskuCDQ==
[x-gm-gg:] => AY/fxX4Y1rtrRrlMku0uj4PzBtEFuefyLLXUoh61n49UUiVux4yMg509S+vBhehzThn G+9u6x76nJ15BX1AIcmiQyGD6eigBc/W3MAtWW1h7fG3epL/5XbjpZ1aow4OWQTJUnr9FTM6dCk lHk2h9jhshYCw5gq4leooPkBjRDzv/oMOS8Urj8h89SN/D9rskOORvaht086x9HlfDVE7heiujm RlWwEK8qtmWknSweEVt+DevW1CqxjuqoKuyLLTstPwSgoQoPcOw5V8+VHOFFDo1NOP/EA==
[x-google-smtp-source:] => AGHT+IGHPCzeW7fUUjn0jcMRJIS8eHf9GuIX2w39jD6xyyUxNbHpTR7D+yZqoiUNJj173mP3Cjz+YwZuFlDfNEGDX9w=
[x-received:] => by 2002:a53:d609:0:b0:642:1d3:adfa with SMTP id 956f58d0204a3-6466a8f31f0mr2742061d50.52.1766174029313; Fri, 19 Dec 2025 11:53:49 -0800 (PST)
[mime-version:] => 1.0
[references:] => <[email protected]> <CA+7+wVkg0Fzm3vtH6aaecLE4sK8iVnVD9JPmoNxBjXTaaQ9A6A@mail.gmail.com>
[in-reply-to:] => <CA+7+wVkg0Fzm3vtH6aaecLE4sK8iVnVD9JPmoNxBjXTaaQ9A6A@mail.gmail.com>
[from:] => Paul Claridge <[email protected]>
[date:] => Fri, 19 Dec 2025 19:53:38 +0000
[x-gm-features:] => AQt7F2q-uCwslAnjRlYj-v9MLu_bRsz7t5gLRqcK_9Ad1XiUYBmdknZ8LfiZqLA
[message-id:] => <CA+7+wVmNe3KyMMWrEix86p1Db8_6M4MqGRa+DqT9ar538qbS7Q@mail.gmail.com>
[subject:] => Re: Making contact (GNBC-1766164018-12)
[to:] => Good News BIG Team <[email protected]>
[content-type:] => multipart/alternative; boundary="000000000000a0f9330646536f00"
[x-virus-scanned:] => clamav-milter 0.103.12 at ikserver2
[x-virus-status:] => Clean
)

[Parts] => Array
(
[0] => Array
(
[Headers] => Array
(
[content-type:] => text/plain; charset="UTF-8"
)

[Parts] => Array
(
)

[Position] => 3678
[BodyFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/1
[BodyPart] => 1
[BodyLength] => 26
)

[1] => Array
(
[Headers] => Array
(
[content-type:] => text/html; charset="UTF-8"
)

[Parts] => Array
(
)

[Position] => 3778
[BodyFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/2
[BodyPart] => 2
[BodyLength] => 72
)

)

[Position] => 0
[ExtractedAddresses] => Array
(
[from:] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Paul Claridge
)

)

[to:] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Good News BIG Team
)

)

)

)

)
Array
(
[Headers] => Array
(
[from ] => [email protected] Fri Dec 19 19:53:51 2025
[received:] => Array
(
[0] => from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41]) by ikserver2.goodnewsbig.com (8.15.2/8.15.2/Debian-18) with ESMTP id 5BJJroWE063949 for <[email protected]>; Fri, 19 Dec 2025 19:53:51 GMT
[1] => by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-6446c924f9eso2027587d50.1 for <[email protected]>; Fri, 19 Dec 2025 11:53:51 -0800 (PST)
)

[authentication-results:] => ikserver2.goodnewsbig.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com [email protected] header.a=rsa-sha256 header.s=20230601 header.b=gc35Gv8E; dkim-atps=neutral
[dkim-signature:] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766174030; x=1766778830; darn=goodnewsbig.com; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=bifDuUndUAuQRjcvn7+MEfVPfiMqD5tyAwtjf3wba7Y=; b=gc35Gv8EhIyvPCqHZi2NKuh+Zfqetj+AehVQTDkhHjHzqZgfxq9ONvjcT1++BOdtdU T+gBFdRhfygL2o38bSVu6R4e6nvm3d83JdFRHz77+drvZD4h3COahfPO9Stislsa9pXp TqkeU5hhABSvh4FX2xhJ/XpzvLH03oB46s7d9/DqJ98ueMAsi2pNKX8XTrF9ketmwEo2 Hre2bACZVPzfcatgvi+2sO9G3hJdK9TYsUtN0nacnVwC/QBhk0L/ZZCZHHpyDxShlXHn hYO9f1KTPuKTXAvmG/jQoV+v4dz58tvfpLwxboZuXMrtocUhjHoWAt6pXGD54fDZAQM+ ZXVw==
[x-google-dkim-signature:] => v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766174030; x=1766778830; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bifDuUndUAuQRjcvn7+MEfVPfiMqD5tyAwtjf3wba7Y=; b=G8sg8XsEL0fYuZ94oBqwq9BE8whLRuFnje7malEGtj8jab2gT931ah9ohVkP9dAot5 vw5ymYPOp7ItMFd0y2dGgHVAzLyIJBe5PVKJNC99ypY/GBrvUwArLeLiNAelnF/p1wGe A7StxdaSYTVmcSMUCOUPoXXdahs8OkU3Dyn5YOWBSIYFt8MwEmEo5aJPOjiyMcqEdNc/ 9ApWk46xypP+PLMQxLbhieBPIa503ZAZRPmnhLUueTbsRDYqo6DrgzkH9zkLj7p4XGRs WJAeritX/ZCZDX13emu3MJ86Ni3uLwdt+ceV3YlpVsIGxq1hQpwwO8AjipZSJTPdYM9z JYxQ==
[x-gm-message-state:] => AOJu0YzuQjckpIC1gvCqc0c8UIgLQ1sHADpTNE6qt8GGAOwY/tdm/BRE Gos48d1pLkMZynsgCKOP/N1VekbZoLloeFIRkMiFaPZoBlb8w+YDcXYK7bttAme5I55/Nj/lW4e tOLmzIC9NednMqHhyBjjLC8JDKkEGskuCDQ==
[x-gm-gg:] => AY/fxX4Y1rtrRrlMku0uj4PzBtEFuefyLLXUoh61n49UUiVux4yMg509S+vBhehzThn G+9u6x76nJ15BX1AIcmiQyGD6eigBc/W3MAtWW1h7fG3epL/5XbjpZ1aow4OWQTJUnr9FTM6dCk lHk2h9jhshYCw5gq4leooPkBjRDzv/oMOS8Urj8h89SN/D9rskOORvaht086x9HlfDVE7heiujm RlWwEK8qtmWknSweEVt+DevW1CqxjuqoKuyLLTstPwSgoQoPcOw5V8+VHOFFDo1NOP/EA==
[x-google-smtp-source:] => AGHT+IGHPCzeW7fUUjn0jcMRJIS8eHf9GuIX2w39jD6xyyUxNbHpTR7D+yZqoiUNJj173mP3Cjz+YwZuFlDfNEGDX9w=
[x-received:] => by 2002:a53:d609:0:b0:642:1d3:adfa with SMTP id 956f58d0204a3-6466a8f31f0mr2742061d50.52.1766174029313; Fri, 19 Dec 2025 11:53:49 -0800 (PST)
[mime-version:] => 1.0
[references:] => <[email protected]> <CA+7+wVkg0Fzm3vtH6aaecLE4sK8iVnVD9JPmoNxBjXTaaQ9A6A@mail.gmail.com>
[in-reply-to:] => <CA+7+wVkg0Fzm3vtH6aaecLE4sK8iVnVD9JPmoNxBjXTaaQ9A6A@mail.gmail.com>
[from:] => Paul Claridge <[email protected]>
[date:] => Fri, 19 Dec 2025 19:53:38 +0000
[x-gm-features:] => AQt7F2q-uCwslAnjRlYj-v9MLu_bRsz7t5gLRqcK_9Ad1XiUYBmdknZ8LfiZqLA
[message-id:] => <CA+7+wVmNe3KyMMWrEix86p1Db8_6M4MqGRa+DqT9ar538qbS7Q@mail.gmail.com>
[subject:] => Re: Making contact (GNBC-1766164018-12)
[to:] => Good News BIG Team <[email protected]>
[content-type:] => multipart/alternative; boundary="000000000000a0f9330646536f00"
[x-virus-scanned:] => clamav-milter 0.103.12 at ikserver2
[x-virus-status:] => Clean
)

[Parts] => Array
(
[0] => Array
(
[Headers] => Array
(
[content-type:] => text/plain; charset="UTF-8"
)

[Parts] => Array
(
)

[Position] => 3678
[BodyFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/1
[BodyPart] => 1
[BodyLength] => 26
)

[1] => Array
(
[Headers] => Array
(
[content-type:] => text/html; charset="UTF-8"
)

[Parts] => Array
(
)

[Position] => 3778
[BodyFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/2
[BodyPart] => 2
[BodyLength] => 72
)

)

[Position] => 0
[ExtractedAddresses] => Array
(
[from:] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Paul Claridge
)

)

[to:] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Good News BIG Team
)

)

)

)
Array
(
[Type] => html
[Description] => HTML message
[Encoding] => utf-8
[DataFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/2
[Alternative] => Array
(
[0] => Array
(
[Type] => text
[Description] => Text message
[Encoding] => utf-8
[DataFile] => /var/www/html/gnb/ci460/public/uploads/IvKZt9lk/1
)

)

[Subject] => Re: Making contact (GNBC-1766164018-12)
[Date] => Fri, 19 Dec 2025 19:53:38 +0000
[From] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Paul Claridge
)

)

[To] => Array
(
[0] => Array
(
[address] => [email protected]
[name] => Good News BIG Team
)

)

)


So, the issue is I never get the message!

Interestingly the part 2 file never gets written either??

Any help would be much appreciated, thx Paul

+44 7880 528262


There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.