57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Test script for email functionality
|
|
* Run from command line: php test_email.php
|
|
*/
|
|
|
|
require_once 'config.php';
|
|
require_once 'functions.php';
|
|
|
|
echo "=== Email Configuration Test ===\n\n";
|
|
echo "MAIL_ENABLED: " . (MAIL_ENABLED ? 'Yes' : 'No') . "\n";
|
|
echo "SMTP_HOST: " . SMTP_HOST . "\n";
|
|
echo "SMTP_PORT: " . SMTP_PORT . "\n";
|
|
echo "SMTP_ENCRYPTION: " . SMTP_ENCRYPTION . "\n";
|
|
echo "SMTP_USERNAME: " . SMTP_USERNAME . "\n";
|
|
echo "MAIL_FROM: " . MAIL_FROM . "\n";
|
|
echo "MAIL_TO: " . MAIL_TO . "\n";
|
|
echo "PHPMailer available: " . (class_exists('PHPMailer\PHPMailer\PHPMailer') ? 'Yes' : 'No') . "\n\n";
|
|
|
|
echo "=== Sending Test Email ===\n\n";
|
|
|
|
$testXML = <<<XML
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<test_submission>
|
|
<message>This is a test email from SemapForm PHP</message>
|
|
<timestamp>%s</timestamp>
|
|
</test_submission>
|
|
XML;
|
|
|
|
$testXML = sprintf($testXML, date('Y-m-d H:i:s'));
|
|
|
|
$subject = "SemapForm Test Email - " . date('Y-m-d H:i:s');
|
|
|
|
echo "Attempting to send test email...\n";
|
|
echo "Subject: {$subject}\n\n";
|
|
|
|
$result = sendEmail($subject, $testXML);
|
|
|
|
if ($result) {
|
|
echo "\n✓ Email sent successfully!\n";
|
|
echo "Check the recipient inbox and mail.log for details.\n";
|
|
} else {
|
|
echo "\n✗ Email sending failed!\n";
|
|
echo "Check mail.log for error details.\n";
|
|
}
|
|
|
|
echo "\n=== Log File Contents ===\n\n";
|
|
if (file_exists(LOG_FILE)) {
|
|
echo "Last 20 lines of mail.log:\n";
|
|
echo "----------------------------------------\n";
|
|
$lines = file(LOG_FILE);
|
|
$lastLines = array_slice($lines, -20);
|
|
echo implode('', $lastLines);
|
|
} else {
|
|
echo "Log file not found at: " . LOG_FILE . "\n";
|
|
}
|