jacobh Posted January 10, 2007 Posted January 10, 2007 I'm looking for some kind of cron job or script to automatically delete old emails, which are in mbox format on the server. The mbox format is the format that TCH servers currently stores mail in. Does anyone know of how to get such a script? Seems like it should be something that is requested fairly often, but I have been unable to locate anything that will do it. Thanks, Jacob Quote
TCH-Bruce Posted January 11, 2007 Posted January 11, 2007 What are you using to read your mail? Quote
jacobh Posted January 12, 2007 Author Posted January 12, 2007 What are you using to read your mail? Many different apps depending on the circumstance (my Treo, Outlook, sqmail). I mainly want the deleting old emails feature for my spam box (and spam learn), which I don't check so regularly. Apparently it's an easier task if we were using maildir, but the server i am on is using mbox. maildir stores the mails as separate files for each mail, and mbox stores them all in one file. I talked to a support tech about changing to maildir, and he said they would do that sometime in the future, but not now. Do you have any ideas how to make a cron job that will delete old mails from mbox based mail? Quote
TCH-Andy Posted January 12, 2007 Posted January 12, 2007 Why not set Ageing in cpanel, for the email account? This will delete the emails after a certain number of days (as long as they have been downloaded via POP) - it saves you doing a cron. Quote
jacobh Posted January 12, 2007 Author Posted January 12, 2007 Why not set Ageing in cpanel, for the email account? This will delete the emails after a certain number of days (as long as they have been downloaded via POP) - it saves you doing a cron. Because I don't think that will work on the sub folders. I only want this for my "spam", "spam-learn" and "ham-learn" subfolders. Any other ideas? Do you know how to set up a cron to delete emails? Quote
TCH-Andy Posted January 12, 2007 Posted January 12, 2007 well, setting up the cron is the easy bit The slightly more tricky bit is writing the script that will do the job. The file is a simple text file, so the script would need to read line by line looking for headers. Once it had found the headers, it could read them and then delete messages over a certain age. Doing a quick google, I found two that you could modify; expire_mail http://www.cpan.org/scripts/mailstuff/expire_mail.pl Garbmail http://ukms.linux.tucows.com/conhtml/preview/8249.html Both of these would need a little modification to do the task you want, but would at least form a basis to work from. Quote
sylvest Posted April 6, 2007 Posted April 6, 2007 Hi, I'm looking for exactly the same thing for exactly the same reason as jacobh. Did anyone make any further progress with adapting either of these scripts for use at TCH? Thanks - Rowan Quote
sylvest Posted April 15, 2007 Posted April 15, 2007 I have now produced a new version of 'garbmail' (which I've renamed 'trashmail') which works on TCH and does what I (and I think jacobh) want. It seems to be working well for me. I have not published it anywhere yet since it's not 100% tested and I would only consider it a beta release, but if anyone would like to try it, please let me know. Rowan Quote
sirius Posted January 27, 2008 Posted January 27, 2008 Why not set Ageing in cpanel, for the email account? This will delete the emails after a certain number of days (as long as they have been downloaded via POP) - it saves you doing a cron. I can not find where to set up Ageing in cpanel, someone want to tell me how? (and put the info here for others) Thanks! # Quote
TCH-Thomas Posted January 27, 2008 Posted January 27, 2008 It does not seems to be in my cpanel either so maybe the people at cpanel.net removed it in version 11. Quote
TCH-Andy Posted January 27, 2008 Posted January 27, 2008 A lot has changed in the 12 months since the previous comments in this thread. The mail format has changed from mbox for mdir and cpanel has updated to version 11 ( as Thomas says). What do you want to achieve ? Quote
sylvest Posted January 27, 2008 Posted January 27, 2008 I've adapted my "Trashmail" script to use the new mailbox format and it has been running perfectly for months doing exactly what I want, and sending me a weekly report telling me what it's done. In my case I don't want to have to download all my spam by POP3 so I can't use Ageing. I just want the spam to be kept for a while on TCH's servers so if some mail seems to be going missing I can go and look for it in the spam mailbox using webmail, and recover it if it's there. If I haven't missed it after a couple of weeks I figure it's OK to delete it. I'd be happy to share my script with anyone who's interested in exchange for an occasional report saying how well it's working for you... Rowan Quote
sirius Posted January 27, 2008 Posted January 27, 2008 A lot has changed in the 12 months since the previous comments in this thread. The mail format has changed from mbox for mdir and cpanel has updated to version 11 ( as Thomas says). What do you want to achieve ? What I am trying to do is trim the size of several hosting client's mailboxes so they do not fill the entire quota of their accounts. Some just don't seem to be able to get their e-mail clients to delete old mail. I would want to trim the size of all e-mail accounts that exist in a domain. Quote
TCH-Andy Posted January 27, 2008 Posted January 27, 2008 Sirius, I'd suggest that you take up the kind offer from Rowan ( sylvest ) and use a copy of his code, which sounds as if it will do pretty much what you require. Thanks for the offer Rowan Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.