Automatically delete old emails using CPanel

Please log in or register to like posts.


1. Click on the Cron jobs icon in your cpanel
2. Open the cron manager.
3. To delete all the emails under your default account that are older than 10 days, We acan setup a cron that runs during a particular time everday

To do this enter the following information in the following fields:
Minute: 25
Hour: 02
Day: *
Month: *
Weekday: *
Command: /usr/bin/archivemail –quiet –delete –days 7 /home/user/mail/inbox

Replace user with your actual username(i.e cpanel username).
4. Click on the Commit Changes button

5. At 2.25 am all mails that are older than 7 days in your inbox will be deleted.

If you wanted to have all the emails deleted that are older than 2 days you would simply change the –days option to 2

To delete all emails inside your mail directory including sent mail, spam, etc. that are older than 20 days
/usr/bin/archivemail –quiet –delete –days 20 /home/user/mail/*

To delete all the emails of a particular email account of your domain in that inbox that are older than six days deleted…
/usr/bin/archivemail –quiet –delete –days 6 /home/user/mail/

To delete sent mail folder
/usr/bin/archivemail –quiet –delete –days 21 /home/user/mail/


To delete the emails older than 1 month please use the below command

Command: /usr/bin/archivemail –quiet –delete –months 1 /home/user/mail/inbox


Nobody liked ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.