PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; try { $pdo = new PDO($dsn, $database_user, $database_pass, $opt); } catch (PDOException $e) { error_log("ARCHIVE: " . $e . PHP_EOL); http_response_code(501); exit; } // Init Redis, only to mirror the switch rspamd reads $redis = new Redis(); try { $redis->connect('redis-mailcow', 6379); $redis->auth(getenv("REDISPASS")); } catch (Exception $e) { $redis = null; } $request = json_decode(file_get_contents('php://input'), true); if (!is_array($request)) { http_response_code(400); exit; } try { $archive = \Mailcow\Archive\ArchiveModule::create($pdo, \Mailcow\Core\Context::system(), $redis); echo json_encode($archive->journal->prepare($request)); } catch (Throwable $e) { error_log("ARCHIVE: " . $e->getMessage() . PHP_EOL); http_response_code(502); }