1. Go to this page and download the library: Download smartilabs/laravel-imap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\Webklex\IMAP\Commands\ImapIdleCommand::class,
];
namespace App\Console\Commands;
use Webklex\IMAP\Commands\ImapIdleCommand;
use Webklex\PHPIMAP\Message;
class CustomImapIdleCommand extends ImapIdleCommand {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'custom_command';
/**
* Holds the account information
*
* @var string|array $account
*/
protected $account = "default";
/**
* Callback used for the idle command and triggered for every new received message
* @param Message $message
*/
public function onNewMessage(Message $message){
$this->info("New message received: ".$message->subject);
}
}
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\CustomImapIdleCommand::class,
];