php foreach error - will pay
I'm having trouble with the following script:
get these errors:
I need to get it working where it can get the incoming emails with images and at least put them in a folder. i've only done this much with the assistance of evolt website, but in any case if someone can help me get these errors fixed and get this script off the ground i will pay them (if that's an incentive). thanks
!/usr/bin/php -q
Warning: Invalid argument supplied for foreach() in /home/XXXXXX/public_html/XXX/XXX.php on line 11
Warning: Invalid argument supplied for foreach() in /home/XXXXXX/public_html/XXX/XXX.php on line 25
#!/usr/bin/php -q
<?php
include('Mail/mimeDecode.php');
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
$structure = Mail_mimeDecode::decode($params);
foreach ($structure->parts as $part) {
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);
}
}
$list = '';
foreach ($structure->parts as $part) {
// is this an image?
if ($part->ctype_primary=='image') {
$list .= $part->ctype_parameters['filename'].': '.
strlen($part->body)." bytes\n";
}
}
// send this list
$to = $structure->headers['from'];
$subject = 'Re: '.$structure->headers['subject'];
$body = "You sent us these images:\n\n$list\n\nThank you very much!";
$headers = 'From: '.$structure->headers['to'];
mail($to, $subject, $body, $headers);
?>
|