|
stefano - 2024-10-17 14:18:06
Hi Manuel,
this code
$mime->Analyze($decoded[0], $results)
gives me the following error:
MIME message analyse error - this multipart/report message is not well formed because it does not define the report type -Pos.: -1
the error is persistent with error messages from various smtp servers, below is an example of these messages:
=====================================================
echo '<pre>';
print_r($decoded[0]);
echo '</pre>';
Array
(
[Headers] => Array
(
[return-path:] => <>
[delivered-to:] => mydomain.it-mysender@mydomain.it
[received:] => Array
(
[0] => (qmail 4108 invoked by uid 89); 17 Oct 2024 13:44:02 -0000
[1] => from unknown (HELO mxdhfe04.ad.myserver.it) (10.10.10.214) by mxdhbe01.ad.myserver.it with SMTP; 17 Oct 2024 13:44:02 -0000
[2] => from smtpcmd12145.myserver.it ([62.149.156.145]) by myprovider MailXchanger with ESMTPS id 1QmAtKn1X8mHC1QnKtLSab; Thu, 17 Oct 2024 15:44:02 +0200
)
[x-spam-report:] => v=2.4 cv=IvdMc6/g c=1 sm=1 tr=0 ts=671114a2 cx=a_exe a=/UVYU+3R4hj3gN7DbDLfJg==:117 a=HpEJnUlJZJkA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=qb6YsvRPBWn5fhlQHN0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=J1z7buqOgbwwgOWytw8A:9 a=ZXulRonScM0A:10 a=zZCYzV9kfG8A:10 a=Rqa-asHnL9zvSTMPGngA:9 a=Pjvn1DhJAAAA:8 a=XSsYFdOxAAAA:8 a=JSJSLJEb_z_E6MXQYCAA:9 a=EuZSfeFH9MJHJ4WD:21 a=lqcHg5cX4UMA:10 a=wPNLvfGTeEIA:10 a=Zo0xKvSedko69A-FG1Xf:22 a=pp1Hn_T0dC5POHkfIA8b:22
[date:] => Thu, 17 Oct 2024 15:44:02 +0200
[from:] => mail-daemon@smtpdh12.ad.myserver.it
[to:] => mysender@mydomain.it
[subject:] => Recapito fallito
[mime-version:] => 1.0
[content-type:] => multipart/report; boundary="------------I305M09060309060P_033817291726420"
[x-cmae-envelope:] => MS4xfIWWhuk4ZpqVcTdrgrsgTHySG8bYGS92qFPl38ECFbLjVOB+kOuQ1ayizHtqTx/qGWYutGBr0tDCReLbKFUkL92X/AkuiK6ki+P8IoVzjMlAQTnum2jf O2tAkM+DUMAjeX70qo2WKX3bQOC879GtoxGXLlAirDcdd1wdFgK57L145koT5KwvFeKiSJ4cDJYBEw==
[x-spam-rating:] => mxdhbe01.ad.myserver.it 1.6.2 0/1000/N
)
[Parts] => Array
(
[0] => Array
(
[Headers] => Array
(
[content-type:] => text/plain; charset=UTF-8;
[content-transfer-encoding:] => 8bit
)
[Parts] => Array
(
)
[Position] => 1512
[Body] => This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed permanently:
* giullogongabonga7632@libero.it
Reason: 1QnJtDFEGTSwm1QnKtLG29 Siamo spiacenti, il tuo messaggio non รจ stato recapitato. Il server destinatario ha risposto: 550 Invalid Recipient [smtp-23.iol.local; LIB_520]
etc etc
Manuel Lemos - 2024-10-19 13:17:11 - In reply to message 1 from stefano
Hello Stefano,
Can you pass a link to a URL that I can use to download a sample message in MIME format, so I can reproduce the issue?
stefano - 2024-10-19 14:10:27 - In reply to message 2 from Manuel Lemos
hi Manuel,
thanks for the reply
just send an email with a non-existent address and wait for the reply email (error) from the server ...
I checked with libero.it (giullogongabonga7632@libero.it) and with gmail.com (rampollozzone.griyllozyu@gmail.com).
from this link you can get one of the messages that generate the mime parser analysis error: https://emma.cloud.tabdigital.eu/s/c2F3EBmd5wqgtAm
Regards
Manuel Lemos - 2024-10-30 08:08:33 - In reply to message 3 from stefano
Hello Stefano,
Sorry for the delay. I am busy finishing a few projects.
Can you wait until the weekend so I can pay more attention to this?
stefano - 2024-10-31 19:02:23 - In reply to message 4 from Manuel Lemos
no problem Manuel, There's no hurry
stefano - 2024-10-31 19:09:31 - In reply to message 5 from stefano
.... There's no hurry also because in the meantime I did this workaround:
if($mime->Analyze($decoded[0], $results)) {
... ok ...
} else {
//echo $mime->error." -Pos.: " . $mime->error_position . "\n";
echo "<br><b>Object</b>: " .$decoded[0]["Headers"]["subject:"] . "<br>";
echo "Date: " .$decoded[0]["Headers"]["date:"] . "<br>";
echo "Sender: " .$decoded[0]["Headers"]["from:"] . "<br>";
echo "<b>Body</b>:</p> <hr>";
$html=$decoded[0]["Parts"][0]["Body"];
.... etc etc
}
Manuel Lemos - 2024-11-03 17:11:03 - In reply to message 3 from stefano
Hello Stefano,
This sample message helped reproduce the problem.
It seems that some messages do not explicitly set the report type.
I added automatic detection of the report type by checking the types of parts contained in the multipart report.
I just uploaded the new version with this improvement.
Can you try it now and let me know if it works well for you?
stefano - 2024-11-05 12:01:00 - In reply to message 7 from Manuel Lemos
Hi Manuel,
now the function $mime->Analyze($decoded[0], $results)
works correctly even with an error email from the pop3 server (eg. 550-5.1.1 The email account that you tried to reach does not exist.)
But now, in the case of error emails from the pop3 server, the field $results["Data"], containing the body of the email, is not set and the body of the email is stored in the field $result["Response"] .
This is not a big problem, just;
if (isset($results["Data"])){
do something with $results["Data"])
} else {
do the same with $results["Response"]);
}
I also noticed a probable regression error (deprecated null passed to trim) in rfc822_addresses.php
on line 615:
$local_part = trim($local_part);
instead of
$local_part = trim((string)$local_part);
Thanks for your availability
see you soon
Manuel Lemos - 2024-11-06 00:16:22 - In reply to message 8 from stefano
Hello Stefano,
Can you provide a minimal script that I can use to reproduce those issues?
stefano - 2024-11-06 09:15:38 - In reply to message 9 from Manuel Lemos
Hi Manuel,
i use this code:
$pop3->GetConnectionName($connection_name);
$message=$_GET['n_email'];
$message_file='mlpop3://'.$connection_name.'/'.$message;
$mime=new mime_parser_class;
$mime->decode_bodies = 1;
$parameters=array(
'File'=>$message_file,
'SkipBody'=>0,
);
$success=$mime->Decode($parameters, $decoded);
$success=$mime->Decode($parameters, $decoded);
if($success)
{
if($mime->Analyze($decoded[0], $results))
{
echo "<p><b>Object</b>: " . $results["Subject"] . "<br>";
echo "Date: " . $results["Date"] . "<br>";
echo "Sender: " . $results["From"][0]["address"] . "<br>";
echo "<b>Body E-mail</b>: <hr>";
if (isset($results["Data"])){
$html = iconv("UTF-8", "ISO-8859-1", $results["Data"]);
} else {
$html = iconv("UTF-8", "ISO-8859-1", $results["Response"]);
}
$html = $purifier->purify($html);
print "$html<hr>";
}
}
|