<?php
/**
 * Veluno Live Server Mail Tester
 */

// Enable full error reporting to see output on the screen
error_reporting(E_ALL);
ini_set('display_errors', 1);

$to = "itwizinfotech@gmail.com";
$subject = "Veluno Live Server Email Test";
$message = "<html>
<head>
    <title>Veluno Mail Test</title>
</head>
<body style='font-family: Arial, sans-serif; padding: 20px; line-height: 1.6;'>
    <h2 style='color: #0b3e70;'>Veluno Live Server Mail Test</h2>
    <p>This is a test email sent from the live server hosting Veluno B2B Lead Portal.</p>
    <p>If you received this, the standard PHP mail() function is working perfectly on your server!</p>
    <hr style='border: none; border-top: 1px solid #ddd;'>
    <p style='font-size: 12px; color: #777;'>Time of Send: " . date("Y-m-d H:i:s") . "</p>
</body>
</html>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: Veluno Test <no-reply@veluno.in>" . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

echo "<!DOCTYPE html>
<html>
<head>
    <title>Veluno Mail Tester</title>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body class='bg-light py-5'>
<div class='container'>
    <div class='row justify-content-center'>
        <div class='col-md-6'>
            <div class='card shadow border-0 rounded-4'>
                <div class='card-header bg-primary text-white py-3 rounded-top-4'>
                    <h4 class='mb-0'>Veluno Mail Tester</h4>
                </div>
                <div class='card-body p-4'>
                    <p class='text-secondary'>Attempting to send a test HTML email to: <br><strong>$to</strong></p>";

// Trigger PHP Mail function
$success = mail($to, $subject, $message, $headers);

if ($success) {
    echo "  <div class='alert alert-success mt-3'>
                <strong>SUCCESS!</strong> PHP reports the email was accepted for delivery by the server's mail system.
            </div>
            <p class='small text-muted'>Please check the inbox and spam folder of <strong>$to</strong>.</p>";
} else {
    echo "  <div class='alert alert-danger mt-3'>
                <strong>FAILURE!</strong> The server failed to accept the email for delivery.
            </div>
            <p class='small text-muted'>This indicates standard PHP mail() is blocked or not configured on this server. You may need to ask host support to enable it or configure SMTP.</p>";
}

echo "              <a href='index.php' class='btn btn-outline-secondary w-100 mt-4'>Back to Homepage</a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>";
?>
