PHP Classes

Problems with size of atachments

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  Problems with size of atachments  >  (Un) Subscribe thread alerts  
Subject:Problems with size of atachments
Summary:When decode a message the size of attachment may be wrong
Messages:4
Author:Juan Alvarez
Date:2018-06-07 16:11:57
 

 


  1. Problems with size of atachments   Reply   Report abuse  
Picture of Juan Alvarez Juan Alvarez - 2018-06-07 16:11:57
Hi Manuel, i have this working in other server, but sometimes i have problem with the size reading of a message.

I put this in a new server and now i can not read any new message, because the size of the message attached of parser is wrong.

I use your example ...

<title>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</title>

I set the user and password, the mail is reading ok.

But the attachment part here in your decode code is 3510 bytes as you can see, but i download the document from roundcube and the document is 6.347 bytes

Do you know what to change for read (decode) the complete attachment ?

Here is some of the decode process.

["Parts"]=>
array(2) {
[0]=>
array(6) {
["Headers"]=>
array(2) {
["content-type:"]=>
string(25) "text/plain; charset=utf-8"
["content-transfer-encoding:"]=>
string(4) "7bit"
}
["Parts"]=>
array(0) {
}
["Position"]=>
int(3031)
["Body"]=>
string(37) "Sob_13.xml
"
["BodyPart"]=>
int(1)
["BodyLength"]=>
int(37)
}
[1]=>
array(8) {
["Headers"]=>
array(3) {
["content-type:"]=>
string(67) "application/octet-stream; name=Sob_13.xml"
["content-transfer-encoding:"]=>
string(6) "base64"
["content-disposition:"]=>
string(57) "attachment; filename=Sob_13.xml"
}
["Parts"]=>
array(0) {
}
["Position"]=>
int(3185)
["FileName"]=>
string(35) "Sob_13.xml"
["FileDisposition"]=>
string(10) "attachment"
["Body"]=>
string(3510) "
a large content ...."
["BodyPart"]=>
int(2)
["BodyLength"]=>
int(3510)
}
}

Regards, Juan

  2. Re: Problems with size of atachments   Reply   Report abuse  
Picture of Juan Alvarez Juan Alvarez - 2018-06-07 19:31:18 - In reply to message 1 from Juan Alvarez
I see the debug information

$debug=1; /* Output debug information */
$html_debug=1; /* Debug information is in HTML */

and before this echo

echo '<h2>MIME message decoding successful</h2>'."\n";

there was all the data in bytes in base64 format.

I decoded the data by other program and the content was all 6.347 bytes. The content was complete.

So i set this before decode

$mime->ignore_syntax_errors = 0;

The result was:

MIME message decoding error: truncated message body part

What can i do now ?

  3. Re: Problems with size of atachments   Reply   Report abuse  
Picture of Juan Alvarez Juan Alvarez - 2018-06-07 19:51:44 - In reply to message 1 from Juan Alvarez
I set the warnings:

if($mime->Analyze($decoded[0], $results))
{
echo '<h2>Message analysis</h2>'."\n";
echo '<pre>';
var_dump($results);
echo '</pre>';

echo 'INICIO WARNINGS ----------------';
for($warning = 0, Reset($mime->warnings); $warning < count($mime->warnings); Next($mime->warnings), $warning++)
{
$w = Key($mime->warnings);
echo 'Warning: ', $mime->warnings[$w], ' at position ', $w;
if($mime->track_lines
&& $mime->GetPositionLine($w, $line, $column))
echo ' line '.$line.' column '.$column;
echo "\n";
}
echo 'FIN WARNINGS ----------------';

}
}

And the result was:

Warning: truncated message body part at position 8192

It seems some configuration with this amount of bytes.
What do you think ?

  4. Re: Problems with size of atachments   Reply   Report abuse  
Picture of Juan Alvarez Juan Alvarez - 2018-06-08 15:24:57 - In reply to message 1 from Juan Alvarez
The solution was:

$mime->message_buffer_length = 8000;

After reading a lots of articles and php pages.

In this one says that fread can not read more than 8192 bytes.

ibm.com/developerworks/library/os-p ...

So i try with setting the attribute message_buffer_length in 8192.

This not worked, tried again with 8000 and voila !

That worked fine !

 
For more information send a message to info at phpclasses dot org.