Delete emails in account by cron

kamm

Well-Known Member
Jan 17, 2004
62
1
158
Spain
cPanel Access Level
Root Administrator
I'd like to delete all emails in an account's inbox that are older than 1 month on a daily basis.

What would be the best way to go about this?

I'm thinking cron with a PHP script?

But, UAPI / API 1 / API 2 - which one to use?
 
Last edited by a moderator:

kamm

Well-Known Member
Jan 17, 2004
62
1
158
Spain
cPanel Access Level
Root Administrator
Hi @cPRex, yes I'm thinking that might be easier. So far I have this,

find /home/cpanel_user/mail/example.com/backups/cur -type f -mtime +30 -delete
find /home/cpanel_user/mail/example.com/backups/new -type f -mtime +30 -delete

Which works OK.

Any tips on how can recalibrate the maildirsize?
 

kamm

Well-Known Member
Jan 17, 2004
62
1
158
Spain
cPanel Access Level
Root Administrator
Thanks.

It seems I can do this to target just the one account without removing the file first.

Code:
/scripts/generate_maildirsize --force --confirm  cpanel_user