table(self::TABLE) ->where('Status', 1) ->orderBy('ID') ->get(); } catch (\Throwable $exception) { Log::warning('route_mail_config_load_failed', [ 'UserID' => $userId, 'message' => $exception->getMessage(), ]); return; } foreach ($configs as $config) { self::sendOnce($userId, $config); } } private static function sendOnce($userId, $config) { $mark = trim((string) ($config->MailMark ?? '')); if ($mark === '') { return; } if (!RouteMailSendLog::markSent($userId, $mark)) { return; } try { PrivateMail::sendMail( 2, $userId, (string) $config->TitleString, (string) $config->TextString, '', 'route_mail_' . $mark . '_' . $userId, 0, 3 ); } catch (\Throwable $exception) { DB::connection('write')->table(RouteMailSendLog::TABLE) ->where('UserID', $userId) ->where('MailMark', $mark) ->delete(); Log::warning('route_mail_send_failed', [ 'UserID' => $userId, 'MailMark' => $mark, 'message' => $exception->getMessage(), ]); } } }