Home > OS >  Sending reminder by checking it everyday
Sending reminder by checking it everyday

Time:12-06

I am new to laravel. What I want to achieve is I want a function that runs everyday automatically. It will be function that send emails to multiple receipients. It will also checking whether it should send by certain condition. I look up internet and found about commands and task scheduler. However, it does not work. Nothing shows up(Error or email).

this is my command:

public function handle()
{ 
 $mail = User::where('id','=',$coordinator)->first();

 $data = [
        'name'     => $mail->name,
        'username' => $mail->staffid,
        'email'    => $mail->email
        ];                  

    Mail::send('email.AssignCoordinator', ["data1"=>$data], function($message) use ($data) {
            $message->from('[email protected]', 'Testing');
            $message->to($data['email']);
            $message->subject('Test: Role Assign');
        });
}

this is my kernel.php:

protected function schedule(Schedule $schedule)
    {
        $schedule->command('delay:mail')
                 ->everyMinute();
    }

Note: I using everyminute() for testing

CodePudding user response:

You should run the scheduler by running php artisan schedule:run Or to set a cron : https://laravel.com/docs/8.x/scheduling#running-the-scheduler

  • Related