mardi 30 avril 2019

Limit sending email Laravel in once schedule task

kindly need your help. I have problem with limit email exchange from SMTP. I have counting table with specific column. total is 201. that total will send email automatic with schedule task on the server.

Counting TOTAL
enter image description here

can I send email per batch using laravel as much as 201 email in once send email ?

cronEmail

/**
 * The name and signature of the console command.
 *
 * @var string
 */
protected $signature = 'email:reminder';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Command description';

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

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function handle()
{
    $this->updateMailConfig();
    $check = DB::table('a_kpi')->join('d_mem','k_created_by','m_id')
    ->leftjoin('a_kpid','kd_kpi_id','k_id')
    ->where('k_status_id',1)
    ->where(function($query){
        $query->where('kd_status_id','=','In Progress')
                ->orwhere('kd_status_id','=',null)
                ->orwhere('kd_status_id','=')
                ->orwhere('kd_status_id','=','null')
                ->orwhere('kd_status_id','=',"null");
    })
    ->get();

    $dt = date("Y-m-d");
    $dtdt = date( "Y-m-d", strtotime( "$dt +10 day" ) );
    for ($i=0; $i <count($check); $i++) { 
        if ($check[$i]->kd_duedate == $dtdt) {
           $mail = $check[$i]->m_email;
            Mail::send('mail.tes', 
                ['pesan'         => 'KPI INFORMATION',
                 'k_label'       => $check[$i]->k_label,
                 'kd_tacticalstep'  => $check[$i]->kd_tacticalstep,
                 'kd_duedate'     =>  $check[$i]->kd_duedate], 
            function ($message) use ($mail)
            {
                $message->subject('REMINDER');
                $message->to($mail);
            });


            $data = DB::table('d_log_reminder')
                                    ->insert([
                                    'dlr_id'=>$check[$i]->k_id,
                                    'dlr_kpi_id'=>$check[$i]->k_id,
                                    'dlr_kpid_id'=>$check[$i]->kd_id,
                                    'dlr_tacticalstep'=>$check[$i]->kd_tacticalstep,
                                    'dlr_label'=>$check[$i]->k_label,
                                    'dlr_duedate'=>$check[$i]->kd_duedate,
                                    'dlr_created_by'=>$check[$i]->k_created_by,
                                    'dlr_send_to'=>$mail
                                    ]);


        }
    }


    // $check = DB::table('d_mem')->where('m_username','admin')->update(['m_code'=>'cor'.date('d-m-y h:i:s')]);

}

}

Kernel.php

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use App\Helper\ConfigUpdater;
use Mail;
use DB;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
    use ConfigUpdater;

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        'App\Console\Commands\cronEmail'
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {


            $schedule->command('email:reminder')
            ->everyMinute();
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2PEad4s
via IFTTT

Aucun commentaire:

Enregistrer un commentaire