Closed alphaolomi closed 2 years ago
Great package and kudos to the author(s).
How to reproduce Ref: https://github.com/Webklex/laravel-imap/issues/431#issuecomment-1236884534
Create new project laravel new imap-demo && cd imap-demo
install the package composer require webklex/laravel-imap
Now the require
of the composer.json
is
"require": {
"php": "^8.0.2",
"ddeboer/imap": "^1.14",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7",
"php-imap/php-imap": "^5.0",
"webklex/laravel-imap": "^4.0"
},
IMAP_HOST="imap.gmail.com" IMAP_PORT=993 IMAP_ENCRYPTION=ssl IMAP_VALIDATE_CERT=true IMAP_USERNAME="XXXXX@gmail.com" IMAP_PASSWORD="XXXXXX" IMAP_DEFAULT_ACCOUNT="default" IMAP_PROTOCOL=imap
4. I added a custom Artisan command `php artisan make:command ImapTestCommand`
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command; use Webklex\IMAP\Facades\Client;
class ImapTestCommand extends Command { /**
@var string */ protected $signature = 'imap:test';
/**
@var string */ protected $description = 'Command description';
/**
@return int */ public function handle() { $client = Client::account("default"); $client->connect();
//Get all Mailboxes
/** @var \Webklex\PHPIMAP\Support\FolderCollection $folders */
$folders = $client->getFolders(false);
//Loop through every Mailbox
/** @var \Webklex\PHPIMAP\Folder $folder */
foreach($folders as $folder){
$this->info("Accessing folder: ".$folder->path);
$messages = $folder->messages()->all()->limit(3, 0)->get();
$this->info("Number of messages: ".$messages->count());
/** @var \Webklex\PHPIMAP\Message $message */
foreach ($messages as $message) {
$this->info("\tMessage: ".$message->message_id);
$this->info("\tBody: ".$message->getHTMLBody());
}
}
return 0;
} }
Sorry guys, It works now
Hi @alphaolomi , Can you please tell me how did you resolved this issue?
Hello @vikrantisk, I recreated the project from scratch, used a fresh Mailbox for testing with minimal number of email, and my conclusion is issue https://github.com/Webklex/laravel-imap/issues/431 still exists in some cases
Describe the bug Empty body when fetching emails
To Reproduce Steps to reproduce the behavior:
Expected behavior Email body should be present in the body
Screenshots Problem is reproducible without screenshots
Desktop / Server (please complete the following information):
Additional context Connection is okay It fetches folders ok It fetches emails ok It failed to load messages body On the mail servers for this case Gmail it registers emails as read since the it assumes the body is read