Skip to main content

Delete all emails in Trash via SSH

Comments

13 comments

  • cPanelMichael
    Hello, The following option exists under "WHM Home " Service Configuration " Mailserver Configuration": "Auto Expunge Trash" When this option is enabled, the system will remove messages in the Trash and Deleted Messages folders based on the expiration time configured for the "Trash Expire Time" option. Once you have configured this option, you can initiate the removal of the emails manually using the following command:
    /scripts/dovecot_maintenance
    Otherwise, you'd need to manually remove the emails from the .Trash directory via SSH. It's located at:
    /home/$username/mail/$domain/$email-account/.Trash
    Thank you.
    0
  • marlowmedia
    Thanks @cPanelMichael Running the script now, much appreciated!
    0
  • marlowmedia

    [dovecot_maintenance] Setting I/O priority to reduce system load: best-effort: prio 4 Expiring trash for "mike@DOMAIN.co.uk" in the "INBOX.Trash" mailbox "Done
    @cPanelMichael I've ran the script and it says its completed removing the emails from my account but they are still all there? So moving onto the second option you gave you said i have to delete all the emails in the directory, can you explain a little more exactly what im deleting as within the directory you told me theres other folders (cur, new, tmp) and files (dovecot files). Or am i literally just deleting everything within the .Trash folder including the sub folders and dovecot files? If not what command would i use to delete everything within a specific folder? Thanks, Mike
    0
  • cPanelMichael
    @cPanelMichael I've ran the script and it says its completed removing the emails from my account but they are still all there?

    Hello, Could you confirm your email client is configured to use IMAP? Thank you.
    0
  • marlowmedia
    I can confirm, its how iv setup Outlook to connect to my email address. Thanks, Mike
    0
  • marlowmedia
    @cPanelMichael I've tried to sort this by removing my email account from Outlook so that the emails are not synced back to the Trash Folder. tried running the SSH command again but it does nothing any more, then i tried changing the auto perge setting from 30days to 15 days and tried running the script and it still did nothing (no response like last time). I've left the server overnight hoping the auto perge script would work but all the emails are still in the Trash folder. What should i do? Thanks, Mike
    0
  • cPanelMichael
    Hello, Can you verify the emails exist on the server in the /home/$username/mail/$domain/$email-account/.Trash location? Thank you.
    0
  • marlowmedia
    Hi, Yes i can confirm, the cur folder has 44.5mb of files in there and new folder has 26.4mb of files whilst tmp has 4.0kb of files. Thanks, Mike
    0
  • marlowmedia
    Heres a screenshot for you.
    0
  • cPanelMichael
    Hello, Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome. Thank you.
    0
  • marlowmedia
    @cPanelMichael it seems iv found a new bug within cPanel/WHM. The Ticket ID is 8313381. Can you update this post with a summary so other people who may have the same issue as me know what to do please. Theres now a new internal case with the following id: CPANEL-12072. Thanks, Mike
    0
  • cPanelMichael
    Hello, Internal case CPANEL-12072 is open to address an issue where emails that are directly filtered to a Trash folder do not result in an added entry to the /var/cpanel/dovecot/dict.sqlite "expires" table, and thus are not removed until the email account actually manually puts an email in the Trash. I'll update this thread with more information on the status of this case as it becomes available. In the meantime, the workaround is to manually delete an email via Webmail or an IMAP-based email client to trigger the record in the /var/cpanel/dovecot/dict.sqlite "expires" table. Thank you.
    0
  • bear
    This is likely the same issue I've been seeing and have a separate thread on, so subbing to this one also. ;)
    0

Please sign in to leave a comment.