mail_mimedecode embedded image in html, can't get the attachment

From: Date: Mon, 22 May 2006 23:47:50 +0000
Subject: mail_mimedecode embedded image in html, can't get the attachment
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24115@lists.php.net to get a copy of this message
hi all i've been working on this script to get attached jpegs out of emails from standard input to a php script, but i am only having partial luck at the moment basically i am working with a telco to process received mms images to use on our site one telco (t1) we are working with, i have no issues getting the image attachment out, it works fine but this other telco (t2), for some reason, i can't find the attachment
       $fh_in = fopen("php://stdin", "r");
       while (!feof($fh_in)) {
           $curr_line = fread($fh_in, 1024);
           $email .= $curr_line;
       }
             fclose($fh_in);
       $message = new Mail_mimeDecode($email);
       $params['include_bodies'] = true;
       $params['decode_bodies']  = true;
       $params['decode_headers'] = true;
       $mailObj = $message->decode($params);
//the problem lies at the line below, as it iterates through it never finds the attached image, only finding ctype_primary = multipart, ctype_secondary = related // no ctype_primary = image, ctype_secondary = jpeg
               foreach($mailObj->parts as $key => $val) {
                   $tmpObj = $mailObj->parts[$key];
                   if (!empty($tmpObj->body)) {
                       if ($tmpObj->ctype_primary == 'image' && $tmpObj->ctype_secondary == 'jpeg' && strlen($tmpObj->body) > 2000) {
                           //process attachment
                       }
                   }
               }
that is basically the code i'm using to process the attachment, but it's not working (received directly from t2 server as an email) the funny thing is, when i forward an email i receive from t2 from "outlook" to this script address, it works without a problem example of the email content type primary - multipart secondary - related ---------------------------------> this is what it looks like after being forwarded through outlook, it has the correct content types stdClass Object ( [headers] => Array
       (
           [content-type] => image/jpeg; name="19052006.jpg"
           [content-transfer-encoding] => base64
           [content-id] => <1148027748l.10501l.96367l@mtaapp03>
           [content-location] => 19052006.jpg
       )
[ctype_primary] => image [ctype_secondary] => jpeg [ctype_parameters] => Array
       (
           [name] => 19052006.jpg
       )
[body] => ÿØÿà -------------------------->stops here also, when i spoof the from from address and attach some html/image using mimePart, and send to the script it works Sample headers of the mms email received in my inbox Return-Path: <A5O5n0Nf-.c_sYsy-3.9c-8piSFrmxbgd8dBm4CNg@mmsserver.com> Delivered-To: 2-myaddress.com Received: (qmail 7171 invoked from network); 19 May 2006 08:36:21 -0000 Received: from mtainet1.tbpa.mmsmserver.com (HELO mtaweb01.mmsmserver.com) (139.7.147.196) by myaddress.com with AES256-SHA encrypted SMTP; 19 May 2006 08:36:21 -0000 Received: from [10.210.160.196] (helo=mtaapp03-c0) by mtaweb01.mmsmserver.com with esmtp (Exim 4.53) id 1Fh0Sb-0002Ph-Iq for myaddress.com; Fri, 19 May 2006 10:35:49 +0200 Received: from [127.0.0.1] (helo=localhost) by mtaapp03-c0 with smtp (Exim 4.50) id 1Fh0Sb-0007GA-BM for myaddress.com; Fri, 19 May 2006 10:35:49 +0200 Date: Fri, 19 May 2006 08:35:47 +0000 From: 00491721570313 <A5O5n0Nf-.c_sYsy-3.9c-8piSFrmxbgd8dBm4CNg@mmsmserver.com> To: myaddress.com Message-Id: <A5fZVQ_HnagDU70Ls@rn2mmscs404>
Received: from [10.210.168.77] (helo=rn2mmscs404)    by mtaapp03-c0
   with esmtp (Exim 4.50)    id 1Fh0Sa-0007Fj-30    for myaddress.com;
Fri, 19 May 2006 10:35:48 +0200 Received: by mms.mmsmserver.com ; Fri, 19 May 2006 08:35:48 GMT MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-hKj0vY7L4RRME7wAtDeS" ----------------------------------------------------------------------------------> then there is like the html source of the email, which is just regular html the attached image is like <img width="71" height="43" border="0" src="cid:1148027748l.10501l.96369l@mtaapp03"/> i'm absolutely out of answers here, what really drives me nuts is that the email is really, no different from the one we receive from t1, yet the code does not work in the same way. Can anyone help me out, throw up any other ideas, tests that I can try to get this working? thanks dave

« previous php.pear.general (#24115) next »