You have an email inbox that is filled up. Or perhaps your “spam box” is filled up. You have so many emails to delete that it would take you forever to clear it out, page by page with NeoMail. One of my customers cried for help because of 35 MBs of spam that had accumulated.
It is time for drastic action. I say “drastic” because this cron job will delete all the emails in one fell swoop. And it will delete all emails that are in the email inbox everytime it runs. There is no recovery path for getting any of those emails back. Nonetheless, in some cases deleting all emails is justified. I use this with some accounts. I might be deleting real emails, but there is so much crap, that I feel it is worth it. Just so you know the downside of this cron job.
Here is the syntax for deleting all email in the inbox of the default email address for a website:
echo -n > /home/youraccount/mail/inbox
Replace youraccount with your site login name (for example, the name you use to FTP to your site).
To determine the path to another email address, log into your site via FTP. Go to the mail directory (it is at the same level as public_html). Here you will see other email addresses as directory names. Click around, there might be subdirectories that you want to work with. To delete mail from a different email address, replace inbox above with the path you found while exploring via FTP.
Good luck. Happy email deleting. I think it feels good to blow away all that email. And I do it regularly for some accounts using this handy cron job.











Thanks for the tips. My needs are a little different, and I am out of my element, maybe you can help me. There is some glitch either with exim or cpanel, my host isn’t clear, and the 30 POP accounts mailbox size never updates properly. To see the correct size and check if a box is approaching quota, I need to delete the “maildirsize” file in each POP’s mail folder.
The path is ~/ mail / xyz.net / user /maildirsize
(xyz.net in place of the domain name)
Can I do a cron job with a wildcard in the “user” directory to delete this file daily in all the 30 POPs (without wiping anything else out, of course)? Any help appreciated.
Thx
You can use a wildcard * with a cron job. A cron job to delete a single maildirsize file is
rm /home/username/mail/domainname.com/emailaccount/maildirsize
To delete from 30 email accounts for your domain, use a wildcard * in place of emailaccount
Thus, your cron would become
rm /home/username/mail/domainname.com/*/maildirsize
I don\’t have direct experience with this issue, but the blog Techo Musings has more detail about this issue: http://hackthetech.blogspot.com/2006/12/cpanel-mail-quota-mismatch.html
Hope this helps!
That’s a handy tip. I’m using one cronjob to train spam assassin and another to empty the junk folder after SA has analyzed all the emails. Thanks!
how do you delete the email in the MAIN account in cpanel
On the main login screen, look in the section called “Mail.”
You should see an icon and link labeled “Webmail.” Follow this link and it will take you to the main account.
I was spending too much of my time checking and deleting emails from the main email accounts so I now blackhole all email that goes to this account. You set this by following the link for “Default Address” (also in the “Mail” section of the main login screen).