Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
869 changes: 60 additions & 809 deletions organizer/src/class/Extraction/ThreadEmailExtractorEmailBody.php

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions organizer/src/class/Imap/ImapEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
require_once __DIR__ . '/../Extraction/ThreadEmailExtractorEmailBody.php';

use Exception;
use Laminas\Mail\Storage\Message;
use ThreadEmailExtractorEmailBody;
use ZBateson\MailMimeParser\MailMimeParser;

class ImapEmail {
public int $uid;
Expand Down Expand Up @@ -137,16 +137,13 @@ public function getEmailAddresses($rawEmail = null): array {

if ($rawEmail !== null) {
try {
$message = ThreadEmailExtractorEmailBody::readLaminasMessage_withErrorHandling($rawEmail);
$x_forwarded_for = $message->getHeaders()->get('x-forwarded-for');
if ($x_forwarded_for !== false ) {
if ($x_forwarded_for instanceof ArrayIterator) {
foreach ($x_forwarded_for as $header) {
$addresses[] = $header->getFieldValue();
}
}
else {
$addresses[] = $x_forwarded_for->getFieldValue();
$message = ThreadEmailExtractorEmailBody::parseEmail($rawEmail);
// Get all X-Forwarded-For headers (there can be multiple)
$xForwardedForHeaders = $message->getAllHeadersByName('x-forwarded-for');
foreach ($xForwardedForHeaders as $header) {
$value = $header->getValue();
if ($value !== null && $value !== '') {
$addresses[] = $value;
}
}
}
Expand All @@ -165,8 +162,11 @@ public function getEmailAddresses($rawEmail = null): array {

static function getEmailSubject($eml_or_partial_eml) {
try {
$message = new Message(['raw' => $eml_or_partial_eml]);
$subject = $message->getHeader('subject')->getFieldValue();
$message = ThreadEmailExtractorEmailBody::parseEmail($eml_or_partial_eml);
$subject = $message->getHeaderValue('subject');
if ($subject === null) {
$subject = '';
}
}
catch (Exception $e) {
$subject = 'Error getting subject - ' . $e->getMessage();
Expand Down
2 changes: 1 addition & 1 deletion organizer/src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "proprietary",
"require": {
"phpmailer/phpmailer": "^6.10",
"laminas/laminas-mail": "2.25.1",
"zbateson/mail-mime-parser": "^3.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete migration leaves api.php broken

High Severity

The laminas/laminas-mail dependency is removed from composer.json, but api.php still imports and uses Laminas\Mail\Storage\Message directly on lines 5 and 39. When this file is executed, PHP will throw a fatal "Class not found" error because the Laminas library is no longer installed. The file needs to be updated to use ThreadEmailExtractorEmailBody::parseEmail() like the other migrated files.

Fix in Cursor Fix in Web

"ext-pdo": "*",
"ext-pdo_pgsql": "*"
},
Expand Down
Loading