From e06b571e7d983feec947b629292962cb794b57cd Mon Sep 17 00:00:00 2001 From: Guillaume ARNOUX Date: Mon, 22 Jan 2024 16:24:05 +0100 Subject: [PATCH] edit request method --- src/Mailcow.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Mailcow.php b/src/Mailcow.php index b592526..b51f197 100644 --- a/src/Mailcow.php +++ b/src/Mailcow.php @@ -75,25 +75,26 @@ class Server_Manager_Mailcow extends Server_Manager { $host = 'https://' . $this->_config['host'] . '/api/v1/'; - // Server credentials + // Server headers $headers['X-API-Key'] = $this->_config['accesshash']; + $headers['Content-Type'] = 'application/json'; // Send POST query $client = $this->getHttpClient()->withOptions([ 'verify_peer' => false, 'verify_host' => false, - 'timeout' => 10 + 'timeout' => 25 ]); $response = $client->request($type, $host . $path, [ 'headers' => $headers, - 'body' => $params != [] ? $params : null + ...$params ]); $result = $response->getContent(); if (str_contains($result, 'authentication failed')) { throw new Server_Exception('Failed to connect to the :type: server. Please verify your credentials and configuration', [':type:' => 'Mailcow']); } elseif (str_contains($result, 'error')) { - error_log("Mailcow returned error $result for the " . $params['cmd'] . 'command'); + error_log("Mailcow returned error $result for the " . $path . ' command');] } return $result;