Automatically delete old emails using CPanel

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

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: