Implement IMAP email-to-ticket gateway
This commit is contained in:
1 parent
b7e5884457
commit
6f25869345
33 files changed
+5619
-5
No files matched your search
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
if (count($argv) > 2 || (isset($argv[1]) && $argv[1] !== '--force')) {
|
||||
fwrite(STDERR, "Usage: php tools/poll.php [--force]\n");
|
||||
exit(1);
|
||||
}
|
||||
require dirname(__DIR__, 3) . '/load.php';
|
||||
try {
|
||||
$result = $di['mod_service']('mailgateway')->poll(($argv[1] ?? '') === '--force');
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
|
||||
$failed = array_filter($result['mailboxes'], fn ($mailbox) => $mailbox['status'] !== 'completed'
|
||||
|| $mailbox['failed'] > 0 || $mailbox['retry_pending'] > 0 || $mailbox['move_pending'] > 0);
|
||||
exit($failed === [] ? 0 : 2);
|
||||
} catch (Throwable) {
|
||||
fwrite(STDERR, "Mail Gateway polling failed. Check the module tables, configuration, and cron logs.\n");
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user