no message
This commit is contained in:
parent
588f6f5b2b
commit
f3bc2fc001
@ -585,50 +585,55 @@ final class Cron
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$sDate = date("Y-m-d");
|
||||
$aSmtp = DB::select('SELECT * FROM smtp_list WHERE `day_clear_date` != "'.$sDate.'" AND `day_count` < `day_max` ORDER BY `day_clear_date` ASC LIMIT 1 FOR UPDATE SKIP LOCKED');
|
||||
try {
|
||||
$sDate = date("Y-m-d");
|
||||
$aSmtp = DB::select('SELECT * FROM smtp_list WHERE `day_clear_date` != "'.$sDate.'" AND `day_count` < `day_max` ORDER BY `day_clear_date` ASC LIMIT 1 FOR UPDATE SKIP LOCKED');
|
||||
|
||||
if (empty($aSmtp) || !isset($aSmtp[0])) {
|
||||
echo Tools::toDateTime(time()) . ' 今日以没有可用smtp' . PHP_EOL;
|
||||
break;
|
||||
}
|
||||
$oSmtp = $aSmtp[0];
|
||||
|
||||
$email_queues_raw = DB::select('SELECT * FROM email_queue where `type` = "bulk" LIMIT 1 FOR UPDATE SKIP LOCKED');
|
||||
|
||||
if (count($email_queues_raw) === 0) {
|
||||
DB::commit();
|
||||
break;
|
||||
}
|
||||
|
||||
$email_queues = array_map(static function ($value) {
|
||||
return (array) $value;
|
||||
}, $email_queues_raw);
|
||||
$email_queue = $email_queues[0];
|
||||
echo '发送邮件至 ' . $email_queue['to_email'] . PHP_EOL;
|
||||
DB::delete('DELETE FROM email_queue WHERE id = ?', [$email_queue['id']]);
|
||||
|
||||
if (Tools::isEmail($email_queue['to_email'])) {
|
||||
try {
|
||||
|
||||
Mail::send_bulk(
|
||||
$email_queue['to_email'],
|
||||
$email_queue['subject'],
|
||||
$email_queue['template'],
|
||||
json_decode($email_queue['array']),
|
||||
$oSmtp
|
||||
);
|
||||
|
||||
DB::update("UPDATE smtp_list SET `day_count` = `day_count` + 1 WHERE id = ".$oSmtp->id);
|
||||
|
||||
} catch (Exception|ClientExceptionInterface $e) {
|
||||
echo $e->getMessage();
|
||||
if (empty($aSmtp) || !isset($aSmtp[0])) {
|
||||
echo Tools::toDateTime(time()) . ' 今日以没有可用smtp' . PHP_EOL;
|
||||
DB::commit();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
echo $email_queue['to_email'] . ' 邮箱格式错误,已跳过' . PHP_EOL;
|
||||
}
|
||||
$oSmtp = $aSmtp[0];
|
||||
|
||||
$email_queues_raw = DB::select('SELECT * FROM email_queue where `type` = "bulk" LIMIT 1 FOR UPDATE SKIP LOCKED');
|
||||
|
||||
DB::commit();
|
||||
if (count($email_queues_raw) === 0) {
|
||||
DB::commit();
|
||||
break;
|
||||
}
|
||||
|
||||
$email_queues = array_map(static function ($value) {
|
||||
return (array) $value;
|
||||
}, $email_queues_raw);
|
||||
$email_queue = $email_queues[0];
|
||||
echo '发送邮件至 ' . $email_queue['to_email'] . PHP_EOL;
|
||||
DB::delete('DELETE FROM email_queue WHERE id = ?', [$email_queue['id']]);
|
||||
|
||||
if (Tools::isEmail($email_queue['to_email'])) {
|
||||
|
||||
|
||||
Mail::send_bulk(
|
||||
$email_queue['to_email'],
|
||||
$email_queue['subject'],
|
||||
$email_queue['template'],
|
||||
json_decode($email_queue['array']),
|
||||
$oSmtp
|
||||
);
|
||||
|
||||
DB::update("UPDATE smtp_list SET `day_count` = `day_count` + 1 WHERE id = ".$oSmtp->id);
|
||||
|
||||
|
||||
} else {
|
||||
echo $email_queue['to_email'] . ' 邮箱格式错误,已跳过' . PHP_EOL;
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
} catch (Exception|ClientExceptionInterface $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo Tools::toDateTime(time()) . ' 群发邮件队列处理完成' . PHP_EOL;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user