<?php
// mail_test.php
// Works on GoDaddy cPanel using PHP's internal mail() function (no open SMTP ports required)

// --- CONFIGURATION ---
$to       = "mehedym@gmail.com";           // recipient
$from     = "contact@mdaemon.academy";     // must be a valid mailbox on your cPanel domain
$subject  = "GoDaddy cPanel Mail Test";
$message  = "Hello,\n\nThis is a test email sent using PHP mail() on GoDaddy cPanel.\n\n--\nServer: " . $_SERVER['SERVER_NAME'];

// --- HEADERS ---
$headers  = "From: $from\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

// --- ENVELOPE SENDER (important for deliverability) ---
$envelope_sender = "-f$from";

// --- SEND ---
if (mail($to, $subject, $message, $headers, $envelope_sender)) {
    echo "✅ Mail sent successfully! Check your inbox or cPanel > Track Delivery.";
} else {
    echo "❌ Mail failed to send. Please check error_log or contact GoDaddy support.";
}
?>
