[imp] over quota and can't delete mail

Michael Sims mhsims at midsouth.rr.com
Thu Dec 12 08:25:24 PST 2002


On Thu, 12 Dec 2002 11:46:07 +0800, you wrote:

>Dear all,
>
>I cannot delete the mail when I am already overquota. By default, I will=
 move the 
>deleted mail to Trash but when I am overquota, this operation is not =
allowed. 
>
>I am using IMP 3.1 , Cyrus, Postfix
>
>Are there any ways I can work around it? 

I hacked Message.php so that if a user is over quota and attempts to delete
a message, the message is automatically expunged permanently.  Not a completely
elegant solution, since it's unexpected behavior, but it suits my particular needs.
If you're interested, a patchfile is below.  I don't think I can send attachments to the
list, so it's inline.  I've turned off word wrapping in my email client, but if something
else causes the patch not to work let me know and I'll send you the file directly.

--- horde/imp/lib/Message.php	Thu Dec 12 07:54:27 2002
+++ horde_patched/imp/lib/Message.php	Thu Dec 12 07:56:18 2002
@@ -219,9 +219,23 @@
                             IMP_Folder::create($imp['stream'], $trash_folder, $prefs->getValue('subscribe'));
                         }
                         if (!imap_mail_copy($imp['stream'], $msg, $trash_folder, CP_UID | CP_MOVE)) {
-                            Horde::raiseMessage(sprintf(_("There was an error moving messages to the trash. This is what the server said")) .
-                                                ': <i>' . imap_last_error() . '</i>', HORDE_ERROR);
-                            $return_value = false;
+                            
+                            $lastError = imap_last_error();
+                            /* 
+                            If message cannot be moved to trash due to quota,
+                            delete and expunge it.
+                            */
+                            if (preg_match("/over.*quota/i", $lastError)) {
+                                if (!imap_delete($imp['stream'], $msg, FT_UID)) {
+                                    Horde::raiseMessage(sprintf(_("There was an error deleting messages from the folder \"%s\". This is what the server said"),
+                                                                IMP::displayFolder($msg_folder)) . ': <i>' . imap_last_error() . '</i>', HORDE_ERROR);
+                                    $return_value = false;
+                                }
+                            } else {
+                              Horde::raiseMessage(sprintf(_("There was an error moving messages to the trash. This is what the server said")) .
+                                                  ': <i>' . $lastError . '</i>', HORDE_ERROR);
+                              $return_value = false;
+                            }
                         }
                     } else {
                         if (!imap_delete($imp['stream'], $msg, FT_UID)) {
@@ -249,9 +263,23 @@
                         IMP_Folder::create($imp['stream'], $trash_folder, $prefs->getValue('subscribe'));
                     }
                     if (!@imap_mail_copy($imp['stream'], $msg_list, $trash_folder, CP_UID | CP_MOVE)) {
-                        Horde::raiseMessage(sprintf(_("There was an error moving messages to the trash. This is what the server said")) .
-                                            ': <i>' . imap_last_error() . '</i>', HORDE_ERROR);
-                        $return_value = false;
+                    
+                        $lastError = imap_last_error();
+                        /* 
+                        If messages cannot be moved to trash due to quota,
+                        delete and expunge them.
+                        */
+                        if (preg_match("/over.*quota/i", $lastError)) {
+                            if (!imap_delete($imp['stream'], $msg_list, FT_UID)) {
+                                Horde::raiseMessage(sprintf(_("There was an error deleting messages from the folder \"%s\". This is what the server said"),
+                                                            IMP::displayFolder($msg_folder)) . ': <i>' . imap_last_error() . '</i>', HORDE_ERROR);
+                                $return_value = false;
+                            }
+                        } else {
+                              Horde::raiseMessage(sprintf(_("There was an error moving messages to the trash. This is what the server said")) .
+                                                  ': <i>' . $lastError . '</i>', HORDE_ERROR);
+                              $return_value = false;
+                        }
                     }
                 } else {
                     if (!@imap_delete($imp['stream'], $msg_list, FT_UID)) {



More information about the imp mailing list