sendTest($to); $answer['success'] = 1; $answer['message'] = 'Test email sent to ' . htmlspecialchars($to) . '.'; } catch (Exception $e) { $answer['message'] = $e->getMessage(); http_response_code(in_array($e->getMessage(), [ 'Invalid recipient email address.', 'No SMTP configuration found. Please save your settings first.', ], true) ? 422 : 500); } exit(json_encode($answer)); ?>