windows - 限制在一次计划任务中发送电子邮件 Laravel
问题描述
我有限制来自 SMTP 的电子邮件交换的问题。我有特定列的计数表。总数为 201。该总数将在服务器上自动发送带有计划任务的电子邮件。
计数总计
我可以在一次发送电子邮件中使用 laravel 每批发送多达 201 封电子邮件吗?
cron电子邮件
/**
* 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')]);
}
}
内核.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');
}
}
解决方案
推荐阅读
- macos - persistentStoreForURL 总是返回 nil
- c++ - C++ .cpp 文件无法识别它使用的 .h 类?
- excel - 在VBA中满足条件时在if语句中退出循环
- python - 查找并打开文件 - 使用 Python
- javascript - 与 JavaScript 相比,Java Http GET 请求非常慢?
- python-3.x - 从 Bokeh HTML 文件加载并覆盖其他形状?
- scala - 在 Google Data Fusion 中使用 Spark 工具重命名输出文件
- python - 本地脚本的 Azure 函数“ModuleNotFoundError”
- python - 在linux中如何设置Python以便在使用python时它将使用python3而不是python 2.7
- c - 如果文件大小未知,如何检测分段错误的原因?