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 mail parsing fix * * This script tests the MailMessages::splitMessageParts function * with the problematic email data to ensure it correctly extracts * the email body content. */ // Include the mail class include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/mail/MailMessages.php'); // Test email data (simplified version of your problematic email) $testEmail = 'From otto@igot.africa Fri Jul 04 12:42:26 2025 Return-path: <otto@igot.africa> Envelope-to: cesa-test@cesasce.co.za Delivery-date: Fri, 04 Jul 2025 12:42:26 +0200 Content-Type: multipart/alternative; boundary="------------5dI8t2xRhNeEOa28kiR0qI9d" Message-ID: <6af3a4bb-284c-4875-bb8b-e85fea5160e2@igot.africa> Date: Fri, 4 Jul 2025 12:42:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Fwd: Engineering excellence spotlighted as CESA launches 2025 industry awards To: cesa-test@cesasce.co.za From: Otto Saayman <otto@igot.africa> This is a multi-part message in MIME format. --------------5dI8t2xRhNeEOa28kiR0qI9d Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit <https://swmcommunications.us18.list-manage.com/track/click?u=4aa460d15553ad1a481812177&id=3b4edeed74&e=d256533e87> *Engineering excellence spotlighted as CESA launches 2025 industry awards* */3 July 2025/* - 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. Against this backdrop, Consulting Engineers South Africa (CESA) today announced the launch of the CESA Aon Engineering Excellence Awards 2025, set for 21 August 2025, at Vodacom World, in Midrand. --------------5dI8t2xRhNeEOa28kiR0qI9d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <!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> --------------5dI8t2xRhNeEOa28kiR0qI9d--'; echo "<h1>Mail Parsing Test</h1>"; // Test the parsing $parts = MailMessages::splitMessageParts($testEmail); echo "<h2>Parsed Results:</h2>"; echo "<pre>"; echo "From: " . $parts['from'] . "\n"; echo "Subject: " . (isset($parts['headers']['Subject']) ? $parts['headers']['Subject'] : 'No Subject') . "\n"; echo "Content-Type: " . (isset($parts['headers']['Content-Type']) ? $parts['headers']['Content-Type'] : 'No Content-Type') . "\n"; echo "Boundary: " . $parts['boundary'] . "\n\n"; echo "Text Message Length: " . strlen($parts['text_message']) . "\n"; echo "HTML Message Length: " . strlen($parts['html_message']) . "\n"; echo "Multipart Message Length: " . strlen($parts['multipart_message']) . "\n\n"; echo "Text Message Preview:\n"; echo substr($parts['text_message'], 0, 200) . "...\n\n"; echo "HTML Message Preview:\n"; echo substr($parts['html_message'], 0, 200) . "...\n\n"; echo "All Headers:\n"; print_r($parts['headers']); echo "</pre>"; // Test with the actual data structure echo "<h2>Testing with Data Structure:</h2>"; $data = [ 'recipientSQL' => "SELECT 'cesa@igotafrica.com' AS Email, 'Only Office' AS OfficeName, 'Mr' AS ContactDesignation, 'O' AS ContactInitials, 'Saayman' AS ContactSurname", 'mailContents' => $testEmail ]; $encodedData = base64_encode(json_encode($data)); echo "<p>Encoded data length: " . strlen($encodedData) . "</p>"; // Simulate the processSend function $decodedData = json_decode(base64_decode($encodedData), true); echo "<p>Decoded successfully: " . ($decodedData ? 'Yes' : 'No') . "</p>"; if ($decodedData) { echo "<p>RecipientSQL: " . $decodedData['recipientSQL'] . "</p>"; echo "<p>MailContents length: " . strlen($decodedData['mailContents']) . "</p>"; // Test parsing again $testParts = MailMessages::splitMessageParts($decodedData['mailContents']); echo "<p>Text message extracted: " . (strlen($testParts['text_message']) > 0 ? 'Yes' : 'No') . "</p>"; echo "<p>HTML message extracted: " . (strlen($testParts['html_message']) > 0 ? 'Yes' : 'No') . "</p>"; } // Test the HTML detection fix echo "<h2>Testing HTML Detection Fix:</h2>"; // Test case: Content-Type text/plain but HTML content (like your problematic email) $testEmail2 = 'From: website@cesa.co.za Reply-To: website@cesa.co.za To: cesa@igotafrica.com Subject: Test HTML Detection 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>'; $parts2 = MailMessages::splitMessageParts($testEmail2); echo "<pre>"; echo "Test Case: Content-Type text/plain with HTML content\n"; echo "Content-Type Header: " . (isset($parts2['headers']['Content-Type']) ? $parts2['headers']['Content-Type'] : 'No Content-Type') . "\n"; echo "Text Message Length: " . strlen($parts2['text_message']) . "\n"; echo "HTML Message Length: " . strlen($parts2['html_message']) . "\n"; echo "Detected as HTML: " . (strlen($parts2['html_message']) > 0 ? 'YES - FIXED!' : 'NO - Still broken') . "\n"; echo "HTML Content Preview: " . substr($parts2['html_message'], 0, 100) . "...\n"; echo "</pre>"; // Test case: Regular text email $testEmail3 = 'From: website@cesa.co.za Reply-To: website@cesa.co.za To: cesa@igotafrica.com Subject: Test Text Detection Content-Type: text/plain Date: Fri, 4 Jul 2025 11:42:42 +0000 This is a plain text email. No HTML content here. Just regular text.'; $parts3 = MailMessages::splitMessageParts($testEmail3); echo "<pre>"; echo "Test Case: Regular text email\n"; echo "Content-Type Header: " . (isset($parts3['headers']['Content-Type']) ? $parts3['headers']['Content-Type'] : 'No Content-Type') . "\n"; echo "Text Message Length: " . strlen($parts3['text_message']) . "\n"; echo "HTML Message Length: " . strlen($parts3['html_message']) . "\n"; echo "Detected as Text: " . (strlen($parts3['text_message']) > 0 ? 'YES - Correct!' : 'NO - Wrong') . "\n"; echo "</pre>";