<?php
$ticket = [
'name' => 'Ada', 'email' => 'you@example.com',
'subject' => 'Delivery question', 'category' => 'smtp',
'priority' => 'medium', 'message' => 'How do I verify my domain?',
];
$curl = curl_init('https://app.wazobiamail.com/api/v1/support');
curl_setopt_array($curl, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($ticket, JSON_THROW_ON_ERROR),
]);
$body = curl_exec($curl);
if ($body === false) throw new RuntimeException(curl_error($curl));
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$result = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 300 || ($result['success'] ?? false) !== true) {
throw new RuntimeException($result['message'] ?? 'Ticket submission failed');
}
print_r($result);