Delete emails in account by cron
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?
-
Hey there! Is there a specific reason you need to use an API at all for this work? I would just use some combination of find and mtime to search for the messages and then remove those automatically with the script. 0 -
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? 0 -
maildirsize is just a flat file, so you can remove it and then recreate it with this: /scripts/generate_maildirsize --confirm --allaccounts
and that will take care of it for all the domains on the system.0 -
Thanks. It seems I can do this to target just the one account without removing the file first. /scripts/generate_maildirsize --force --confirm cpanel_user0 -
That's also an option if you only wanted to perform the work on one domain :D 0
Please sign in to leave a comment.
Comments
5 comments