PHP imap_fetchbody没有从电子邮件正文返回文本

I provided credentials: $hostname,$username,$password

<?php
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());
$emails = imap_search($inbox,'ALL');

if ($emails) {
    $output = '';
    rsort($emails);

    foreach ($emails as $email_number) {
        $overview = imap_fetch_overview($inbox,$email_number,0);
        $structure = imap_fetchstructure($inbox,$email_number);
        $message = imap_fetchbody($inbox,$email_number, "1.1");
        $message2 = imap_fetchbody($inbox,$email_number, "1.2");

        $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
        $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
        $output.= '<span class="from">'.$overview[0]->from.'</span>';
        $output.= '<span class="date">on '.$overview[0]->date.'</span>';
        $output.= '</div>';
        $output.= '<div class="body">'.$message.'</div>';
        $output.= '<div class="body">'.$message2.'</div>';
    }            
}

/* close the connection */
imap_close($inbox);

I am able to receive imap_fetch_overview & imap_fetchstructure information.

The structure shows that the messages differ in size and there is actual information in the body of the emails.

Is there any reason imap_fetchbody comes back blank?

Try 2 as the section parameter.

imap_fetchbody($inbox,$email_number,2)

This may help as well, for reference or you could just use the class..

http://blog.geneticcoder.com/2015/05/18/gmail-via-php/