I want to send emails to 100 users. Mail::send() is taking too much load time and isn't able to cover all emails of users. I'm trying to use Mail::queue() in my application, but I'm getting the error below while running
php artisan queue:listen.
[ErrorExcepton] Undefined Property : SuperClosure\SerializableClosure::$binding.
Updated .env file with QUEUE_DRIVER = database.
Please help me find the solution to resolve this. Also, I am using the same code to run background jobs, using Laravel 5.3.
Here is my code
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;
class ProbationCronJobEmail extends Command
{
protected $signature = 'hrm:notify';
protected $description = "";
public function __construct()
{
parent::__construct();
}
public function handle()
{
$email = '[email protected]';
\Mail::queue('emails.probation',
['empname'=>'abc','id'=>'123'],function($msg) use($email){
$msg->from('[email protected]');
$msg->to($email);
$msg->subject('Probation List as on '.date('Y-M-d'));
});
}
}
abc@gmail is a dummy email, i am using my corporate email instead.
if i simple type php artisan hrm:notify, getting no error.
I have a little example. I hope this will help.
In your_app/config/mail.php .
.env file