php-imap
php-imap copied to clipboard
Getting replies for message
Hi) Could someone help me please?) I'd like to get all replies for a message but I get error Call to a member function query() on null vendor/webklex/php-imap/src/Message.php#821
My code is ` $client->connect();
$folder = $client->getFolder($folder->name);
$message = $folder->query()->getMessageByMsgn($letter->msgn);
var_dump($message->thread($sent_folder = null)); // here it crushes
Everything else is working fine, the problem is only with getting replies..`
Hi @jane08 ,
it looks like $folder is null.
Please expand you example a little bit so I or someone else can use your code to replicate the behavior and make guess on whats happening.
Best regards & happy coding,
@Webklex , thank you for your feedback. I checked folder and message - both exist and I can get name of folder and subject of message and even set it as read. Here is the complete code
$cm = new ClientManager($options = []);
// or create a new instance manually
$client = $cm->make([
'host' => $email->host,
'port' => $email->port,
'encryption' => $email->encryption,
'validate_cert' => $validate_cert,
'username' => $email->username,
'password' =>'mypassword',
'protocol' => $email->protocol,
]);
//Connect to the IMAP Server
$client->connect();
$folder = $client->getFolder($dbfolder->name); // folder exists, can get name of folder
$message = $folder->query()->getMessageByMsgn($letter->msgn); // message exists, can get all data
var_dump($message->thread($sent_folder = null)); // here it crushes
I checked Message.php , something goes wrong in here https://prnt.sc/NAgeV2ammaOo But I don't know what)