Dave Fischetti wrote:
>> If you don't mind I do have one quick question about something  
>> different. The parser has been working great for me. All users who  
>> submit images from their phones are parsed and added to their  
>> account. This works great for all users accept those sending emails  
>> from a specific mobile carrier.
>>
>> I check if there is an image with:
>>
>> if ( get_class( $part ) === 'ezcMailFile' ) {
>>
>> and when I get here, this is where I have the problem
>>
>> $my_image = array_values(getimagesize($part->fileName));
>>
>> For this specific carrier, I get this error every time an image is  
>> attached:
>> <b>Warning</b>:  array_values() [<a href='function.array- 
>> values'>function.array-values</a>]: The argument should be an array  
>> in <b>/var/www/vhosts/broadtexter.com/httpdocs/_maintenance/phpcgi/ 
>> inboxManager.php5</b> on line <b>671</b><br />
>>
>> I realize this is probably not a EZ issue. But perhaps there's  
>> something I should be doing differently for messages from this source.
>>
>> Below is an example of the source of a message like this. I'm not  
>> sure whats different here when compared to the other users who get  
>> parsed no problem.
>>
>> Thanks again:
>>
>> Dave
>>
>> Message Source below
>> ------------------------------
>>
>> MIME-Version: 1.0
>> Content-Type: multipart/related; type="text/html";
>>      boundary="----=_Part_659415_20850935.1199378668689"
>> Importance: Normal
>> X-MMS-Message-Type: MM4_forward.REQ
>> X-Priority: 3
>>
>> ------=_Part_659415_20850935.1199378668689
>> Content-Type: text/html
>> Content-Transfer-Encoding: quoted-printable
>> Content-ID: <0000>
>> Content-Disposition: inline
>>
>> <html>
>>
>> [snip]
>>
>> </html>
>>
>> ------=_Part_659415_20850935.1199378668689
>> Content-Type: text/plain; charset=utf-8;  
>> name=smiltextpartfilename0.txt
>> Content-Transfer-Encoding: 7bit
>> Content-Location: smiltextpartfilename0.txt
>> Content-ID: <155>
>> Content-Disposition: inline
>>
>> msg
>> ------=_Part_659415_20850935.1199378668689
>> Content-Type: image/jpeg; name=1231071650a.jpg
>> Content-Transfer-Encoding: base64
>> Content-Location:1231071650a.jpg
>> Content-ID: <156>
>>
>> /9j/4AAQSkZJRgABAQAAAQABAAD/ 
>> 2wBDAAEBAQEBAQEBAQECAQEBAgICAQECAgICAgICAgIDAgMD
>> AwMCAwMEBAQEBAMFBQUFBQUHBwcHBwgICAgICAgICAj/ 
>> 2wBDAQEBAQICAgUDAwUHBQQFBwgICAgI
>> CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAj/ 
>> xAGiAAAABgIDAQAA
>> AAAAAAAAAAAHCAYFBAkDCgIBAAsQAAIBAgUCAwQGBgUFAQMGbwECAwQRBQYhEgAHMUETCFEiYRRx
>> gTKRCaEj8M
> 
> 
> Just following up on my message above regarding warnings I'm getting  
> from emails from specific users phones.
> I solved the Warning problem by changing my code to check if its an  
> array, before using array_values(), but I'm still unsure why the image  
> was missed. All images are missed when they come from this one phone  
> carrier.
> 
> I parsing the mail as follows. Not sure why its being missed. unless  
> the $type value is not 2 even though its a jpg. I'll look into that  
> more.
> 
> 
> foreach ( $parts as $part )
> {
>       if ( get_class( $part ) === 'ezcMailText' && $part->subType ===  
> 'plain' && $bodySet != true )
>       {
>               $bodyFull = trim($part->text);
>               $bodySet = true;
>       }
>       
>       //////   MANAGE INCOMING IMAGE FROM FAN   //////
>       if ( get_class( $part ) === 'ezcMailFile' && $imageSet != true) {
>               
>               $getImage = getimagesize($part->fileName);
>               if (is_array($getImage) && $getImage !== false) {
>                       $my_image = array_values($getImage);
>                       list($width, $height, $type, $attr) = $my_image;
>                       if ($type == 2 && basename($part->fileName)) {
>                               if (filesize($part->fileName) < 4194304) { // 
> only accept images <  
> 4MB
>                                       $imageErr = false;
>                                       $imageSet = true;
>                                       break;
>                               } else {
>                                       $imageErr = 1;
>                                       break;
>                               }
>                       }
>               } else {
>                       $imageErr = 2;
>               }
>       }
> }
> 
> Also, in some cases with this carrier, the content-type "name" does  
> not match the Content-Location. In all my successful parsings so far,  
> it did match. I'm wondering if the parser is looking at Content- 
> Location when it should be looking at the "name" field, or at least  
> using the name field when the 2 don't match.
> 
> Content-Type: image/jpeg; name=me.jpg
> Content-Transfer-Encoding: base64
> Content-Location:media1.jpeg
> Content-ID: <268>
> 
> However
> 
> This seems to be the case with this message, but then again, my  
> message below has the same "name" and Content-Location value. So I'm  
> not sure why its being missed there.

Hi Dave,

The parser uses the filename specified in Content-Type (me.jpg) and not 
the one in Content-Location (media1.jpg). A temporary file is created 
and you access it with $part->fileName (eg. '/tmp/6520-1/me.jpg'). So 
the file in the attachment exists.

You call getimagesize() on the file, which returns false, indicating 
that the file is not an image (and not that the file does not exist, 
because in that case it would throw a warning or notice).

The attachment in your previous mail seems to be a jpeg, but when I open 
it in gimp it says that it is not complete (but maybe you did not put 
all of it in the mail because it would have been too big). I replaced it 
with another image and it works. So I think the image from that mail is 
not supported by getimagesize().

Try copying the temporary file to another directory:

copy( $part->fileName, '/tmp/' . basename( $part->fileName ) );

before you call getimagesize() and open it in an image editor to see if 
the file is really an image.

Hope this helps.

Cheers,
Alex.

-- 
Alexandru Stanoi
eZ Components System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to