exec("CREATE TABLE IF NOT EXISTS hamid_smtp_config ( id SERIAL PRIMARY KEY, host VARCHAR(255), port INT DEFAULT 587, username VARCHAR(255), password VARCHAR(255), from_email VARCHAR(255), from_name VARCHAR(255) DEFAULT 'HAMID IA', active BOOLEAN DEFAULT true )"); $action = $_POST['action'] ?? $_GET['action'] ?? ''; switch ($action) { case 'send': $to = $_POST['to'] ?? ''; $subject = $_POST['subject'] ?? ''; $body = $_POST['body'] ?? ''; $headers = "From: HAMID IA \r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $result = @mail($to, $subject, $body, $headers); echo json_encode(['success' => $result, 'to' => $to]); break; default: echo json_encode(['actions' => ['send', 'configure']]); }