For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2006 > mimedecode issue - no body









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 mimedecode issue - no body
dtra FYF

2006-04-25, 7:04 pm

hi all

ok really annoying issue here

i had this script working where it would take an attached image and process
it (after being piped to by sendmail)
using pear mail, mail_mimedecode

running on php 5.0.4 fedora core 4

PHP:

function parse_email() {
/**
* $origDest - location to put the attached image
* $finalDest - location to put the processed images
* which are then moved by a cron job to the images directory
*/
$origDest '/mail-handler/';
$finalDest $origDest '/processed/';

/**
* Read the stdin - piped data from Sendmail
* and add all the email data into a variable we can read later
*/

$fh_in fopen("php://stdin""r");
while (!
feof($fh_in)) {
$curr_line fread($fh_in1024);
$email .= $curr_line;
 
}
 
fclose($fh_in);
 
/**
* create a new mimeDecode object (provided by PEAR)
* that we can use to grab the attachment from the email
*/
$message = new Mail_mimeDecode($email);
$mailObj $message->decode($params);

$from $mailObj->headers['from'];

$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
// Get and Save the Attachments
$i 0;
foreach(
$mailObj->parts as $key => $val) {
$intRand mt_rand(100000999999);
$tmpObj $mailObj->parts[$key];

if (!empty(
$tmpObj->body)) {
if (
$tmpObj->ctype_primary == 'image' &&
$tmpObj->ctype_secondary == 'jpeg' && strlen($tmpObj->body) > 2000) {
$filename $tmpObj->ctype_parameters['name'];
//processing code

}
}
 
$i++;
}
 
$blah print_r($mailObjtrue);
send_response('myemail'$from .
"\r\n7***********************\r\n" .
$blah);
}



this code was working yesterday, then today, while testing, it seems to have
stopped working

it gets all the filenames, etc, etc. fine
but there is no $tmpObj->body (it is empty)

i have had the script send the print_r result back to me
and all the ctype properties are there, etc.
but no body

sample working response
PHP:

stdClass Object
(
[
headers] => Array
(
[
content-type] => image/jpegname="ATT00154.jpg"
[content-transfer-encoding] => base64
[content-id] => <23abc@pc27-000>
)

[
ctype_primary] => image
[ctype_secondary] => jpeg
[ctype_parameters] => Array
(
[
name] => ATT00154.jpg
)

[
body] => ÿØÿà
// --> see the body above exists



sample response from today, not working
PHP:

stdClass Object
(
[
headers] => Array
(
[
content-type] => image/jpegname="ATT00154.jpg"
[content-transfer-encoding] => base64
[content-id] => <ATT00154.jpg>
[
content-location] => ATT00154.jpg
)

[
ctype_primary] => image
[ctype_secondary] => jpeg
[ctype_parameters] => Array
(
[
name] => ATT00154.jpg
)

)
// --> see no body property above
)



when i have the raw email sent back to me, all the text and encoded image is
there, etc.

i am sending the same emails, from the same addresses using the same format
(i've also tried sending the emails as plain text with attachments, html
emails with embedded image, html, with attached image)

does anyone know what the issue could be?

i have run pear upgrade all, etc, etc.

thanks
dave

Sponsored Links







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

Copyright 2008 codecomments.com