<?php
// Simple email test script
echo "<h1>Email Test</h1>";

// Check if mail function exists
if (!function_exists('mail')) {
    echo "<p style='color:red'>Error: mail() function is not available!</p>";
    echo "<p>Make sure PHP is configured with mail support.</p>";
    exit;
}

// Try to send a test email
$to = "monitor@egonetix.de";
$subject = "Test Email from Luftglanz";
$message = "This is a test email sent from " . $_SERVER['SERVER_NAME'] . " at " . date('Y-m-d H:i:s');
$headers = "From: test@" . $_SERVER['SERVER_NAME'] . "\r\n" .
           "Reply-To: test@" . $_SERVER['SERVER_NAME'] . "\r\n" .
           "X-Mailer: PHP/" . phpversion();

$success = mail($to, $subject, $message, $headers);

if ($success) {
    echo "<p style='color:green'>Success! Test email was sent to $to</p>";
} else {
    echo "<p style='color:red'>Failed to send email. Check server mail configuration.</p>";
    
    // Check mail configuration
    echo "<h2>Mail Configuration:</h2>";
    echo "<pre>";
    echo "sendmail_path: " . ini_get('sendmail_path') . "\n";
    echo "SMTP: " . ini_get('SMTP') . "\n";
    echo "smtp_port: " . ini_get('smtp_port') . "\n";
    echo "</pre>";
}

// Display PHP info for debugging
echo "<h2>PHP Information:</h2>";
echo "<p>PHP Version: " . phpversion() . "</p>";
echo "<p>Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "</p>";
?>
