Decoding mail attachments
| From: | Dave | Date: | Mon, 11 Oct 2004 04:02:51 +0000 |
| Subject: | Decoding mail attachments | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-199140@lists.php.net to get a copy of this message | ||
Hi
I am having trouble running the example from:
http://www.theukwebdesigncompany.co...code-module.php
Am running PHP5.0.2 running on a windows XP box.
I've setup the test email message as:
PHP Code:
$input = "Return-Path: <gvtulder@example.com>
Delivered-To: gijs@localhost
Received: (qmail 4400 invoked from network); 6 Mar 2003 18:13:52 -0000
Received: from unknown (HELO localhost) (gijs@127.0.0.1)
by localhost with SMTP; 6 Mar 2003 18:13:52 -0000
X-Flags: 0000
Delivered-To: GMX delivery to gvtulder@example.com
<!-- snip snip -->"
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
// do the decode
$structure = Mail_mimeDecode::decode($params);
// save the attachment as a file.
foreach ($structure->parts as $part) {
// only save if an attachment
if (isset($part->disposition) and ($part->disposition=='attachment')) {
// open file
$fp = fopen($part->ctype_parameters['filename'], 'w');
// write body
fwrite($fp, $part->body);
// close file
fclose($fp);
}
}
I've included the correct PEAR file..and all quotation marks are escaped
properly in the $input. However I get the following message:
Fatal error: Using $this when not in object context in
c:\php5\PEAR\Mail\mimeDecode.php on line 168
Is this PHP5 being buggy? I need to run in 5 as I'm using simpleXML. In the
bigger picture all I want to decode is XML attached files.
Kind Regards
Dave.