How to get all linked email streams

I am trying to get all email received from a specific email id like (From: abc@gmail.com ) which I receive successfully. Now I am looking forward to receiving all messages that are in the flow for this email, i.e. Re: sub fw :, Re: Re ....

This is how I try

 $username   = 'myemail@gmail.com';
 $password   = 'mypassword';
 $folder     = 'INBOX';

 $email_resp    = $this->config_imap($username,$password,$folder);
 $email_list    = $email_resp['emails'];
 $inbox         = $email_resp['inbox'];
 $student_email = $useremail;
 $email_list    = imap_search($inbox, "FROM '{$student_email}'");
 $threads          = imap_thread($inbox);

rsort($email_list);

    if(sizeof($email_list)>0){

        foreach ($email_list as $key => $value) {

            $overview      = imap_fetch_overview($inbox,$value,0);
            $message       = imap_fetchbody($inbox,$value,2);
            $attachment    = imap_fetchstructure($inbox,$value);
            $threads       = imap_thread($inbox);

            $thread_detail = array(
                  $value.".num"         => $threads[$value.".num"],
                  $value.".next"        => $threads[$value.".next"],
                  $value.".branch"      => $threads[$value.".branch"],
                );
                foreach ($thread_detail as $k => $v) {
                    $tree  =explode('.',$k);
                    if($tree[1]=='num'){
                        $headerInfo=imap_headerinfo($inbox, $value);
                    }

                }
                echo json_encode($headerInfo);
                die;


            $overview[0]->email      =$message;
            $overview[0]->attachment =$attachment;

            $emails[]=$overview;

        }   
        echo json_encode($emails);
    }
    else{
        return Response::json(array('fail'=>'No Email Found.'));
    }

      

How can I get the associated streams header data and message body too.

+3


source to share





All Articles