SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 138 forks source link

Image embedded not able to get REF ID #211

Closed kekatxxx closed 6 years ago

kekatxxx commented 6 years ago

Hi, thanks for the library that I found extremely useful.

Now I encountered a problem: I'm trying to manage the embedded images that are included on the body of the message, but I can get only the $attachment->info properties that not include the "reference ID". To be precise my problem is this:

My mail has the body like this:

<img src="cid:ii_161be4ca41817e30" alt="Immagine incorporata 1" width="530" height="398"> and if I print the info of the email: if(strtolower($attachment->info->structure->disposition) == "inline"){ print_r($attachment->info); }`

I get this:

SSilence\ImapClient\Section Object ( [_structure:SSilence\ImapClient\Section:private] => stdClass Object ( [type] => 5 [encoding] => 3 [ifsubtype] => 1 [subtype] => JPEG [ifdescription] => 0 [ifid] => 1 [id] => [bytes] => 1157606 [ifdisposition] => 1 [disposition] => INLINE [ifdparameters] => 1 [dparameters] => Array ( [0] => stdClass Object ( [attribute] => FILENAME [value] => image.jpeg ) ) [ifparameters] => 1 [parameters] => Array ( [0] => stdClass Object ( [attribute] => NAME [value] => image.jpeg ) ) ) [_body:SSilence\ImapClient\Section:private] => /9j/4AAQSkZJRgABAg....

If I want to get the url, download and replace the body with a new correct path for display the image, I cannot do it, because I haven't the ref ID to replace with.

Searching in the past issues I found that some os those referred to this problem but most of the code is deprecated, like this: https://github.com/SSilence/php-imap-client/issues/57#issuecomment-273604112 (where there it shows the property "reference", that is not present in the $attachment->info array) or this: https://github.com/SSilence/php-imap-client/pull/58 (where we talks about a method embedImages(), that is absent in your last version of the library)

Now, as I can't find some detailed istruction to get these info, could you please help me?

mattparksjr commented 6 years ago

I don't know off the top of my head. @sergey144010 ping. In the mean time just use a laster version

sergey144010 commented 6 years ago

Sorry guys that I can not help you. Over the past year, much has changed in my life and there is simply no time for it. I hope that in the future I'll be back. I changed a lot of code in my branch, I do not even remember exactly what now. I can only advise you to install it and see how it works there. https://github.com/sergey144010/php-imap-client/

disaipe commented 6 years ago

@kekatxxx try use $attachment->info->structure->id

kekatxxx commented 6 years ago

Thanks guys for hepling me. In meanwhile I used another library because I had no time to do a deep study of the code. I hope that my issue will help to improve the next versions. Bye.