Mail_Mime issue

From: Date: Fri, 28 May 2004 17:29:19 +0000
Subject: Mail_Mime issue
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12774@lists.php.net to get a copy of this message
Hello, I'm using the PEAR;;Mail_Mime class to decode incoming Mails and extract the attachments. With normal Textfiles this works well, but if *.gz file are in and I try to extract them is only normal text what I receive. Example Code: function _getAttachments( $part ) {
       // check where we find the filename
       if ( $part->ctype_parameters['name'] ) {
           $filename = $this->_tmpdir.'/'.$part->ctype_parameters['name'];
       } else {
           $filename = $this->_tmpdir.'/'.$part->d_parameters['filename'];
       }
       // open filehandle
       $fh = fopen($filename, 'w+');
             // if encoded so decode and write down to file
       if ( $part->headers['content-transfer-encoding'] == 'base64' ) {
           fwrite($fh, base64_decode($part->body), strlen(base64_decode($part->body)));
       } elseif ( $part->headers['content-transfer-encoding'] == 'utf8' ) {
           fwrite($fh, utf8_decode($part->body), strlen(utf8_decode($part->body)));
       } else {
           fwrite($fh, $part->body, strlen($part->body));          }
       fclose($fh);
             // assign back to files array
       $this->_files[] = array('filename' => $filename, 'type' => 'attachment');
} An then I check the files and see: # file explorer.832ca1fc.spnb56-2004.04.13.08.38.tar.gz
explorer.832ca1fc.spnb56-2004.04.13.08.38.tar.gz:    ascii text
and not
explorer.832ca1fc.spnb56-2004.04.13.08.38.tar.gz:    gzip compressed data - deflate method , original file name
My params for Mail_mimeDecode class are: $this->_params = array(
                           'include_bodies'    => true,
                           'decode_bodies'        => false,
                           'decode_headers'    => true
                           );
What I'm doing wrong? thanks in forward. Cheers -Peter

« previous php.pear.general (#12774) next »