0

I have been using php-imap-client for some time and has always worked great. The issue is that recently it seems to break with fetching email from outlook/office365 mailboxes now and I can't pinpoint the issue. As far as I know it seems to be breaking with imap_fetchbody() but that is as far as I get.

getMessages() basically does not work and I was wondering if anyone has come across this yet and maybe can shed some light to a solution to fix it.

Things like countMessages and countUnreadMessages work fine but once you try get the email contents that is where it breaks.

$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();

Here is all my code

$mailbox = $row['imap_server_address'];
$username = $row['imap_username'];
$password = $row['imap_password'];
$encryption = Imap::ENCRYPT_SSL; // TLS OR NULL accepted

// Open connection
try{
    $imap = new Imap($mailbox, $username, $password, $encryption);
    // You can also check out example-connect.php for more connection options

}catch (ImapClientException $error){
    echo $error->getMessage().PHP_EOL; // You know the rule, no errors in production ...
    die(); // Oh no :( we failed
}

// Select the folder INBOX
$imap->selectFolder('INBOX');

// Count the messages in current folder
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();

// Fetch all the messages in the current folder
echo "This echos fine";
$emails = $imap->getMessages();
echo "This does not echo";
var_dump($emails);

I can connect to the server just fine. I can select the INBOX, I can get overall messages and as well as unread. var_dump($email) produces nothing. And there are unread emails in the inbox.

When I echo after $emails = $imap->getMessages(); nothing is echo'd to the screen so something is breaking here.

4

0 回答 0