<?php
session_start();
require_once '../inc/admin_auth.php';
requireAdmin();
require_once '../inc/functions.php';

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($id) {
    $stmt = $pdo->prepare("DELETE FROM mail_messages WHERE id = ?");
    $stmt->execute([$id]);
    $_SESSION['admin_message'] = '✅ Письмо удалено.';
} else {
    $_SESSION['admin_message'] = '❌ Не указан ID.';
}
header('Location: admin_mail_list.php');
exit;