isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on', 'cookie_httponly' => true, 'use_strict_mode' => true, ]); } // Generate CSRF token if not set if (empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); error_log("test_smtp.php: Generated new CSRF token"); } error_log("test_smtp.php: Script started"); if ($_SERVER['REQUEST_METHOD'] === 'POST') { error_log("test_smtp.php: POST request received"); // Retrieve form inputs $to = trim($_POST['to'] ?? ''); $csrf_token = $_POST['csrf_token'] ?? ''; error_log("test_smtp.php: Recipient: $to, CSRF Token: $csrf_token"); // Test email details $subject = 'Test SMTP Email from PHPMailer'; $message = '

This is a test email sent via PHPMailer

If you received this, SMTP is working!

'; $name = 'Test User'; // Call the send_mail function from mail.php error_log("test_smtp.php: Calling send_mail function"); $result = send_mail($to, $subject, $message, $name, $csrf_token); error_log("test_smtp.php: send_mail result - Status: " . $result['status'] . ", Message: " . $result['message']); // Output the result if ($result['status'] === 'success') { echo '

' . htmlspecialchars($result['message']) . '

'; } else { echo '

' . htmlspecialchars($result['message']) . '

'; } echo '

Send another test

'; } else { error_log("test_smtp.php: GET request - Displaying form"); // Display the form ?> Test SMTP with PHPMailer

Test SMTP

This script uses your configured mail settings from the database to send a test email via PHPMailer.

Ensure your mail settings (SMTP host, port, auth, etc.) are set in the admin panel, and database is configured.