25 lines
1.1 KiB
PHP
25 lines
1.1 KiB
PHP
<?php
|
|
// Direkter Web-Zugriff wird geblockt (nur CLI oder Einbindung aus dem Backend/Pseudo-Cron).
|
|
if (php_sapi_name() !== 'cli' && !defined('DESKHUB_CRON_RUNNER')) { http_response_code(403); exit('Kein Web-Zugriff.'); }
|
|
/**
|
|
* cron/process_mail_queue.php
|
|
*
|
|
* Versucht Mails erneut zu senden, die wegen einer Störung (SMTP-Server nicht erreichbar, falscher Port …) nicht rausgingen.
|
|
* Läuft alle paar Minuten, z. B. per Cronjob:
|
|
* * /5 * * * * /usr/bin/php /pfad/zu/deskhub/cron/process_mail_queue.php
|
|
*/
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
|
|
/** @return array{sent:int, failed:int, retry:int, gave_up:int, log:string[]} */
|
|
function run_process_mail_queue(PDO $pdo, bool $verbose = false): array
|
|
{
|
|
$r = mail_queue_run($pdo);
|
|
set_setting('cron_process_mail_queue_last_run', db_now());
|
|
$r['log'] = ['[' . date('Y-m-d H:i:s') . "] Mail-Warteschlange: {$r['sent']} gesendet, {$r['retry']} später erneut, {$r['gave_up']} aufgegeben."];
|
|
return $r;
|
|
}
|
|
|
|
if (php_sapi_name() === 'cli') {
|
|
foreach (run_process_mail_queue(get_db(), true)['log'] as $line) echo $line . "\n";
|
|
}
|