Php 如何检索电子邮件的所有关联线程

Php 如何检索电子邮件的所有关联线程,php,email,gmail,imap,gmail-imap,Php,Email,Gmail,Imap,Gmail Imap,我正在尝试获取从特定电子邮件id收到的所有电子邮件,例如(从:abc@gmail.com),这是我成功得到的。 现在,我期待着得到所有的信息,这是在线程到这封电子邮件即Re:sub-fw:,Re:Re 下面是我如何尝试的 $username = 'myemail@gmail.com'; $password = 'mypassword'; $folder = 'INBOX'; $email_resp = $this->config_imap($username

我正在尝试获取从特定电子邮件id收到的所有电子邮件,例如(从:abc@gmail.com),这是我成功得到的。 现在,我期待着得到所有的信息,这是在线程到这封电子邮件即Re:sub-fw:,Re:Re

下面是我如何尝试的

 $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.'));
    }
如何获取相关的线程头详细信息和消息正文