From a3b903b75c85568dfb8aa4a59e4664b10b30c84d Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 15 Dec 2017 13:33:04 +0100 Subject: [PATCH] * Mail: Fix empty trash/empty junk actions causes error in some mail servers, e.g. Cyrus. --- api/src/Mail.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index 67811ddd63..6943b0e372 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -3953,8 +3953,9 @@ class Mail $this->flagMessages('delete', $uid, $_folder); } } - // delete the messages finaly - $this->icServer->expunge($_folder); + $examineMailbox = $this->icServer->examineMailbox($_folder); + // examine the folder and if there are messages then try to delete the messages finaly + if (is_array($examineMailbox) && $examineMailbox['MESSAGES'] > 0) $this->icServer->expunge($_folder); break; } if($oldMailbox != '') {