From b2dae09cf14a73d0dcd5c8049585e210611fab47 Mon Sep 17 00:00:00 2001 From: FreeScout Date: Fri, 5 Jan 2024 10:08:21 -0800 Subject: [PATCH] Improve fetching email in Show Original window - closes #3658 --- app/Misc/Mail.php | 7 ++++++- app/Thread.php | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Misc/Mail.php b/app/Misc/Mail.php index e6fb3936a..7a7e1fa81 100644 --- a/app/Misc/Mail.php +++ b/app/Misc/Mail.php @@ -733,6 +733,11 @@ public static function fetchMessage($mailbox, $message_id, $message_date = null) foreach ($imap_folders as $folder_name) { try { $folder = self::getImapFolder($client, $folder_name); + + if (!$folder) { + \Log::error('('.$mailbox->name.') Show Original - folder not found: '.$folder_name); + continue; + } // Message-ID: <123@123.com> $query = $folder->query() ->text('<'.$message_id.'>') @@ -763,7 +768,7 @@ public static function fetchMessage($mailbox, $message_id, $message_date = null) $query = $folder->query()->text('<'.$message_id.'>')->leaveUnread()->limit(1)->setCharset(null); if ($message_date) { $query->since($message_date->subDays(7)); - $query->before($message_date->addDays(7)); + $query->before($message_date->addDays(14)); } $messages = $query->get(); $no_charset = true; diff --git a/app/Thread.php b/app/Thread.php index 2d7591308..c8cf77db5 100644 --- a/app/Thread.php +++ b/app/Thread.php @@ -1393,6 +1393,12 @@ public function fetchBody() { $message = \MailHelper::fetchMessage($this->conversation->mailbox, $this->message_id, $this->getMailDate()); + // Try without limiting by date. + // https://github.com/freescout-helpdesk/freescout/issues/3658 + if (!$message) { + $message = \MailHelper::fetchMessage($this->conversation->mailbox, $this->message_id); + } + if (!$message) { return ''; }