public function fetch($index = null, $params = array(
        'index' => true,
        'overview' => true,
        'structure' => true,
        'header' => true,
        'body' => true,
        'plain' => true,
        'attachments' => true,
    )){
        $params = Arr::mergeWithDefaultParams($params);

        $this->attachments = [];

        if (!$index) {
            $index = 1;
        }

        $this->messageNumber = $index;

        $structure = @imap_fetchstructure($this->conn, $index);

        if (!$structure) {
            return false;
        } else {
            $data = [];

            if($params['index']){
                $data['index'] = $index;
            }

            if($params['overview']){
                $data['overview'] = @imap_fetch_overview($this->conn, $index);
            }

            if($params['structure']){
                $data['structure'] = $structure;
            }

            if($params['header']){
                $data['header'] = @imap_header($this->conn, $index);
            }

            if($params['body']){
                $this->bodyHTML = $data['body'] = @imap_body($this->conn, $index);
            }

            if($params['plain']){
                $data['plain'] = @imap_fetchbody($this->conn, $index, 1.2);
            }

            if($params['attachments']){
                $this->recurse($structure->parts);
                $data['attachments'] = $this->attachments;
            }

            return $data;
        }

    }
public function fetch($index = null, $params = array(
        'index' => true,
        'overview' => true,
        'structure' => true,
        'header' => true,
        'body' => true,
        'plain' => true,
        'attachments' => true,
    )){
        $params = Arr::mergeWithDefaultParams($params);

        $this->attachments = [];

        if (!$index) {
            $index = 1;
        }

        $this->messageNumber = $index;

        $structure = @imap_fetchstructure($this->conn, $index);

        if (!$structure) {
            return false;
        } else {
            $data = [];

            if($params['index']){
                $data['index'] = $index;
            }

            if($params['overview']){
                $data['overview'] = @imap_fetch_overview($this->conn, $index);
            }

            if($params['structure']){
                $data['structure'] = $structure;
            }

            if($params['header']){
                $data['header'] = @imap_header($this->conn, $index);
            }

            if($params['body']){
                $this->bodyHTML = $data['body'] = @imap_body($this->conn, $index);
            }

            if($params['plain']){
                $data['plain'] = @imap_fetchbody($this->conn, $index, 1.2);
            }

            if($params['attachments']){
                $this->recurse($structure->parts);
                $data['attachments'] = $this->attachments;
            }

            return $data;
        }

    }
public function fetch ( $ index = null , $ params = array ( 'index' => true , 'overview' => true , 'structure' => true , 'header' => true , 'body' => true , 'plain' => true , 'attachments' => true , ) ) { $ params = Arr :: mergeWithDefaultParams ( $ params ) ; $ this -> attachments = [ ] ; if ( ! $ index ) { $ index = 1 ; } $ this -> messageNumber = $ index ; $ structure = @ imap_fetchstructure ( $ this -> conn , $ index ) ; if ( ! $ structure ) { return false ; } else { $ data = [ ] ; if ( $ params [ 'index' ] ) { $ data [ 'index' ] = $ index ; } if ( $ params [ 'overview' ] ) { $ data [ 'overview' ] = @ imap_fetch_overview ( $ this -> conn , $ index ) ; } if ( $ params [ 'structure' ] ) { $ data [ 'structure' ] = $ structure ; } if ( $ params [ 'header' ] ) { $ data [ 'header' ] = @ imap_header ( $ this -> conn , $ index ) ; } if ( $ params [ 'body' ] ) { $ this -> bodyHTML = $ data [ 'body' ] = @ imap_body ( $ this -> conn , $ index ) ; } if ( $ params [ 'plain' ] ) { $ data [ 'plain' ] = @ imap_fetchbody ( $ this -> conn , $ index , 1.2 ) ; } if ( $ params [ 'attachments' ] ) { $ this -> recurse ( $ structure -> parts ) ; $ data [ 'attachments' ] = $ this -> attachments ; } return $ data ; } }
Fetch structure by index

@param null $index
@param array $params
@return bool
Fetch structure by index