When using the ImapIdleCommand logic, you can define a callback to handle incoming Webklex\PHPIMAP\Message objects. In the provided implementation, the onNewMessage method is used as the callback for the $folder->idle() method.
To process messages, you should override or implement the onNewMessage method to perform your desired actions, such as logging, database insertion, or notification dispatching.
/**
* Callback used for the idle command and triggered for every new received message
* @param Message $message
*/
public function onNewMessage($message) {
// Your custom logic here
$this->info("New message received: " . $message->subject);
}