how can send multiple mail with cronjobs using laravel?

#1
cron jobs run hourly and daily automatic is not working with devops
hourlyemail.php

Code:
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Jobs\IntervalTaskCreationMailJob;
use DB;
class HourlyMail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'HourlyMail:email';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Hourly mail sending by admin';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
    parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
    $hourly =DB::table('regular_tasks')
        ->leftJoin('regular_task_user','regular_tasks.id', '=','regular_task_user.regular_task_id')
        ->leftJoin('users','regular_task_user.user_id', '=','users.id')
        ->select('regular_tasks.*','users.email')
        ->where('regular_tasks.task_freq', 'hourly')->get();        
       
        foreach($hourly as $d){
        $demail = $d->email;
        IntervalTaskCreationMailJob::dispatch($d,$demail)
        ->delay(now()->addSeconds(10));
        }
             
             
}
}
mail.php

Code:
<?php

namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class HourlySendMail extends Mailable
{
use Queueable, SerializesModels;
public $d;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($d)
{
    $this->d = $d;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
    return $this->from('info@scmgalaxy.com')
    ->subject('Hourly Mail from Devops Team')
    ->view('mails.intervaltaskcreationmail')
    ->with('d', $this->d);
}
}
How i can run my Schedule task every minute, hourly and daily?. When I run command PHP artisan schedule: run, console get "No scheduled commands are ready to run.". How should set my Tasks properly? For example if I use solo command php artisan command:send_info_email_before_event it works, but i want do it with schedule:run when i develop app.
 
Last edited:
Top