|
...
|
...
|
@@ -31,13 +31,18 @@ class SendAutoEmail extends Command |
|
|
|
{
|
|
|
|
$autoEmailLogModel = new AutoEmailLog();
|
|
|
|
$list = $autoEmailLogModel->list(['status'=>AutoEmailLog::STATUS_PENDING],'id',['*'],'asc',100);
|
|
|
|
if(empty($list)){
|
|
|
|
sleep(10);
|
|
|
|
}else{
|
|
|
|
if(!empty($list)){
|
|
|
|
$ids = array_column($list,'id');
|
|
|
|
$autoEmailLogModel->edit(['status'=>AutoEmailLog::STATUS_ON],['id'=>['in',$ids]]);
|
|
|
|
foreach ($list as $value) {
|
|
|
|
$this->toQueue($value);
|
|
|
|
$this->output('开始执行任务:' . $value['id']);
|
|
|
|
$smtpModel = new Smtp();
|
|
|
|
$smtpInfo = $smtpModel->read(['project_id'=>$value['project_id']]);
|
|
|
|
if($smtpInfo === false){
|
|
|
|
$this->output('任务:' . $smtpInfo['id'] . '失败,未配置SMTP');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->toQueue($value,$smtpInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
...
|
...
|
@@ -50,14 +55,7 @@ class SendAutoEmail extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/30 15:43
|
|
|
|
*/
|
|
|
|
public function toQueue($info){
|
|
|
|
$this->output('开始执行任务:' . $info['id']);
|
|
|
|
$smtpModel = new Smtp();
|
|
|
|
$smtpInfo = $smtpModel->read(['project_id'=>$info['project_id']]);
|
|
|
|
if($smtpInfo === false){
|
|
|
|
$this->output('任务:' . $smtpInfo['id'] . '失败,未配置SMTP');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
public function toQueue($info,$smtpInfo){
|
|
|
|
Config::set('mail.mailers.smtp.host', $smtpInfo['host']);
|
|
|
|
Config::set('mail.mailers.smtp.username', $smtpInfo['email']);
|
|
|
|
Config::set('mail.mailers.smtp.password', $smtpInfo['password']);
|
...
|
...
|
|