How to handle multipart/MIXED in imap using php in laravel 7

Viewed 21

I have a program in which i need to get all inbox messages. There are some subtype like: RELATED,ALTERNATIVE,MIXED & PLAIN. I am unable to manage subtype=MIXED using imap_fetchbody() because of this also facing issue with attachments. Check Below Code:

    public function messageBody(Request $req){
    $msg_id = $req->msg_id;
    $folder = $req->folder;
    $stream = $this->connect($folder);
    $structure = imap_fetchstructure($stream, $msg_id);
    if($structure->subtype=="RELATED"){
      $msg_body = imap_fetchbody($stream,$msg_id,"1.2");   
    }else if($structure->subtype=="ALTERNATIVE"){
      $msg_body = (!empty($msg_body)) ? $msg_body : imap_fetchbody($stream,$msg_id,"2");  
    }else if($structure->subtype=="MIXED"){
      $msg_body = (!empty($msg_body)) ? $msg_body : imap_fetchbody($stream,$msg_id,"1");    
    }else{
      $msg_body = (!empty($msg_body)) ? $msg_body : imap_fetchbody($stream,$msg_id,"1");  
    }
    
   
    $msg_body = quoted_printable_decode(imap_utf8($msg_body));
    $overview = imap_fetch_overview($stream, $msg_id);
    return view('mailbox.message-body',compact('msg_id','msg_body','overview','folder'));
  }
0 Answers
Related