For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2004 > Mail_Mime issue









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Mail_Mime issue
Peter Valicek - Senior Cluster Engineer

2004-05-28, 2:36 pm

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com