Skip to main content

Deleting All Catch-All Mails Across All Accounts

Comments

5 comments

  • 24x7server
    Hello, You will have to delete all mail using SSH from cur and new directory which are created under /home/username/mail directory
    0
  • cPanelMichael
    Hello :) Email sent to the default address is stored in:
    /home/$username/mail/cur /home/$username/mail/new
    You can delete all of this email through the use of a wildcard and the "rm" command. There is no single command to use, but you could try something such as:
    mkdir /root/email-to-delete mv /home/*/mail/cur/* /root/email-to-delete/ mv /home/*/mail/new/* /root/email-to-delete/
    Then, simply delete "/root/email-to-delete" when you have confirmed the emails are no longer required. To note, you can ensure emails sent to non-existent email accounts are not delivered to the default address by ensuring your accounts set the "Default Address" to: "Discard with error to sender (at SMTP time)" Thank you.
    0
  • arsytym
    Hello, Thank you for replying to my question. I ran the command, mv /home/*/mail/cur/* /root/email-to-delete/ But I received This: -bash: /bin/mv: Argument list too long I have set all existing account to :fail now - just need to clear out these folders :)
    0
  • cPanelMichael
    You may find this third-party application helpful if you lack command-line experience: Config Server Mail Manage Otherwise, searching for "/bin/mv: Argument list too long" on a search engine will yield useful results. Thank you.
    0
  • ethical
    just wanted to save others the time in "searching for the answer" as Michael suggested use
    find /home/*/mail/cur/* -type f | xargs -i mv "{}" /root/email-to-delete/ or this and slowly increase the mtime value until you can finish with the above line find /home/*/mail/cur/* -type f -mtime +1 -print | xargs -i{} mv {} /root/email-to-delete/
    in my cause my list was even too long for the find command, even when i set it to just do files modified in the lastday (-mtime +1) so i did this and stepped through the alphabet for the home dirs util I could run the above command without error
    find /home/a*/mail/new/* -type f -print | xargs -i{} mv {} /root/email-to-delete/
    0

Please sign in to leave a comment.