Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Delete all emails in Trash via SSH

Discussion in 'E-mail Discussions' started by marlowmedia, Mar 16, 2017.

Tags:
  1. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    Hi,

    I'm trying to sort my work email out, i have over half a million emails in my Trash folder, using SSH how can i delete all the emails in my email Trash folder?

    Its starting to cause a few issues for me with Outlook.

    Thanks,
    Mike
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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:

    Code:
    /scripts/dovecot_maintenance
    Otherwise, you'd need to manually remove the emails from the .Trash directory via SSH. It's located at:

    Code:
    /home/$username/mail/$domain/$email-account/.Trash
    Thank you.
     
  3. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    cPanelMichael likes this.
  4. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    Code:
    [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
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you confirm your email client is configured to use IMAP?

    Thank you.
     
  6. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    I can confirm, its how iv setup Outlook to connect to my email address.

    Thanks,
    Mike
     
  7. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    @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
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Can you verify the emails exist on the server in the /home/$username/mail/$domain/$email-account/.Trash location?

    Thank you.
     
  9. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    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
     
  10. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    Heres a screenshot for you.
     

    Attached Files:

  11. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  12. marlowmedia

    marlowmedia Member

    Joined:
    Oct 25, 2016
    Messages:
    14
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Wigan
    cPanel Access Level:
    Root Administrator
    @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
     
    cPanelMichael likes this.
  13. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  14. bear

    bear Well-Known Member

    Joined:
    Sep 24, 2002
    Messages:
    119
    Likes Received:
    2
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    This is likely the same issue I've been seeing and have a separate thread on, so subbing to this one also. ;)
     
Loading...

Share This Page