SSilence / php-imap-client

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

Inline images come as attachment #175

Open abdullahseba opened 7 years ago

abdullahseba commented 7 years ago

Hi if an email has inline images they load as an attachment and wont show in the html at all. Note the errors from them too. image

abdullahseba commented 7 years ago

dead?

mattparksjr commented 7 years ago

Hi sorry ive been inactive. Ill look into this

abdullahseba commented 7 years ago

Never mind :)

mattparksjr commented 7 years ago

Was it a mistake on your end?

abdullahseba commented 7 years ago

No, the HTML has no images at all. it just comes as an attachment

public function getMessages($request, $response, $args)
  {
    $imap = $this->ci->imap;
    //Get request data from POST.
    $params = $request->getParsedBody();
    //Select mailbox
    $imap->selectFolder($this->getMailboxName($mailbox = $params['currentMailbox']));
    //Get and encode email.
    $messages = array();
    foreach ($params['ids'] as $uid) {
      $id = $imap->getId($uid);
      $email = $imap->getMessage($id);
      $attachments = array();
      foreach ($email->attachments as $attachment ) {
        $attachments[] =   $attachment->name;
      };

      $emailConstruct = array(
        "subject" => $imap->convertToUtf8($email->header->subject),
        "from" => $imap->convertToUtf8($email->header->from),
        "udate" => $email->header->udate,
        "body" => $imap->convertToUtf8($email->message->html->body),
        "attachments" => $attachments
      );
        $path = $this->ci->locator->findResource('sprinkles://webmail/temp/attachments', true, true);
        $imap->saveAttachments(['dir'=>$path]);
         $messages[$uid] = $emailConstruct;
    }
    //Return email.
    return  json_encode($messages);
  }

Than I download the attachments separately for the preview.

mattparksjr commented 7 years ago

Thank you for working around this. We will fix this soon.

mattparksjr commented 7 years ago

@sergey144010 ping

deepak458 commented 6 years ago

i don't know how to decode all of this code can you help for decode all this code & abdullahseba xXXIMMATTHEWXXx if you have any full code then please inform me or give me some tutorial video or website

mattparksjr commented 6 years ago

I dont know what you mean by full code. Our code is available in the repo though.

deepak458 commented 6 years ago

Hello,

Thanks for your reply. I'm a little confused how I use your code to get my emails. Can I use it json or use it on page code.

And when I want to show my mail subject out of foreach it's show only one.

If you have any idea how I can use with Ajax or json then please suggest me.

And how I set set value when someone open mail then mark as read and how to search work.

And how I check its have any attachments then it's show Yes otherwise it's show No. If you have some time then men please help me out.

Thanks Deepak Saini

On Jan 17, 2018 4:26 AM, "Matthew Parks" notifications@github.com wrote:

I dont know what you mean by full code. Our code is available in the repo though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SSilence/php-imap-client/issues/175#issuecomment-358135696, or mute the thread https://github.com/notifications/unsubscribe-auth/Ab5MVnGfz-irRa8iZ8Q_BkfogLAimIv7ks5tLSkGgaJpZM4NvKzR .