<?php
require_once 'includes/config.php';
require_once 'includes/email_functions.php';

// Test email sending
$to = 'ahoststore1@gmail.com'; // Change this to a real email address for testing
$subject = 'Test Email from StoreWeb';
$message = '
<html>
<body>
    <h2>Email Configuration Test</h2>
    <p>This is a test email to verify that the email system is working correctly.</p>
    <p>If you receive this email, it means the email configuration is working.</p>
    <p>Site: ' . SITE_NAME . '</p>
</body>
</html>
';

echo "<h2>Email Test</h2>";

if (sendEmail($to, $subject, $message)) {
    echo "<p style='color: green;'>Email sent successfully to $to</p>";
    echo "<p>Please check your inbox (and spam folder) to confirm receipt.</p>";
} else {
    echo "<p style='color: red;'>Failed to send email. Check your server configuration.</p>";
    echo "<h3>Troubleshooting Tips:</h3>";
    echo "<ul>";
    echo "<li>Make sure your server supports the mail() function</li>";
    echo "<li>Check if sendmail is properly configured on your server</li>";
    echo "<li>For Gmail, consider using App Passwords with 2-Factor Authentication</li>";
    echo "<li>For production environments, consider installing PHPMailer for better reliability</li>";
    echo "</ul>";
}

echo "<p><a href='index.php'>Back to Home</a></p>";
?>