Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2004, 10:46 PM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to fgraph
Default 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);


?>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in integration of pay go! ostwald ASP.NET 2.0 Professional 1 November 3rd, 2007 03:30 PM
Need Help Desparately - will pay for phone consult Michele_Haywood Access 6 November 8th, 2006 11:39 AM
Getting Error in foreach loop for DataSet bravipandey ADO.NET 2 September 28th, 2005 06:43 PM
Total Gross Pay chadfran Crystal Reports 2 June 10th, 2005 01:49 PM
"foreach" error BradBrening Pro PHP 2 January 13th, 2005 05:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.