Jump to content

Recommended Posts

Posted

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

Posted
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?

Posted

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.

Posted
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?

Posted

well, setting up the cron is the easy bit :thumbup: 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.

  • 2 months later...
Posted

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

  • 2 weeks later...
Posted

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

  • 9 months later...
Posted
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!

 

#

Posted

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 ?

Posted

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

Posted
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.

Posted

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 :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...