I am not receiving any email. Please help me out. I have changed the environment properly.
use App\User;
use App\Mail\NotifyEmail;
class Notify extends Command
{
protected $signature = 'notify:email';
protected $description = 'Send an email to all the users everyday';
public function handle()
{
$emails = User::pluck('email')->toArray();
$data = ['title' => 'programming' , 'body' => 'php'];
foreach($emails as $email){
Mail::To($email) ->send(new NotifyEmail($data));
}
}
}
My kernel.php has :
$schedule->command('notify:email') ->daily();
App\Mail\NotifyEmail.php
:
class NotifyEmail extends Mailable
{
use Queueable, SerializesModels;
public $details;
public function __construct($data)
{
$this -> details = $data;
}
public function build()
{
return $this->view('mail', compact(varname: 'details'));
}
}
mail.blade.php
contains {{$details['title']}}
and {{$details['body']}}
.
CodePudding user response:
If it is a Queueable, you will need a separate process to run the queue continuously. Without that process, the queue entries just stack up and never get processed. See the Laravel Queue documentation https://laravel.com/docs/9.x/queues#running-the-queue-worker about running queues and/or run artisan queue:work
CodePudding user response:
have you setup the cron job in crontab? if not nothing would run
read https://laravel.com/docs/8.x/scheduling#running-the-scheduler