MASSMEDIUMS - Responsive Web Design Cincinnati MASSMEDIUMS - Responsive Web Design Cincinnati

Delete all emails from a cPanel account via SSH

There are times when you may need to delete all emails from a particular account in cPanel. Deleting individual emails in your webmail application or email client, or even a page at a time can be daunting if you have 100's or 1000's of emails to delete.

To save valuable time, you can connect to the server via SSH and delete all emails quickly and easily with the commands below. SSH can be dangerous, so this method is only recommended for those comfortable with SSH commands. If you don’t know what you are doing you could cause serious, irreparable damage to your website. Proceed with caution.

To delete all emails in an account, log into your cPanel account via SSH and run the following command:

/* Delete all files recursively in a particular email account */
rm -rf ~/mail/DOMAIN.COM/ACCOUNT/{*,.*}
/* The following deletes catch-all and default email for all WHM users  */
find /home/*/mail/new/ -type f -print0 | xargs -0 rm
find /home/*/mail/cur/ -type f -print0 | xargs -0 rm
find /home/*/mail/dovecot* -type f -print0 | xargs -0 rm

If you would only like to delete specific directories, run any of the following commands:

/* Navigate to the email account. Each command removes a specific directory */
cd ~/mail/DOMAIN.COM/ACCOUNT/
rm -rf cur
rm -rf new
rm -rf .Sent
rm -rf .Junk
rm -rf .Trash
/* The following command removes all dovecot files */
rm dovecot*
  • Home
  • Blog
  • Manually remove a Joomla 3.x component
Ready to get started? Let us take your website to the next level. LET'S TALK
MASSMEDIUMS has been essential in the growth of our company, delivering high-impact marketing tools and a first-rate web presence

, VP, Ziegler Practice Transitions