Koozali.org: home of the SME Server
Obsolete Releases => SME Server 7.x => Topic started by: lightman on March 09, 2011, 09:32:02 PM
-
Hello.
I was looking for a way to automatically empty trash in all accounts.
we have around 100 users that just forget to do it and the size of the mails increases a lot!.
I have seen an old post (didn't reply there because it's 3 year old), How to automatically delete spam (http://forums.contribs.org/index.php?topic=40635.0) it is not exactly what I need but very close :D
Can anyone please give me a hint of how to do that?, I don't want a free easy solution, just an explanation of how, so I can write my own script :), well, what ever you can tell me will help for sure :)
thank you A LOT! in advance :D
Leo
-
Why not configure all your users mail clients to purge trash on exit? What mail clients are you using?
-
Why not configure all your users mail clients to purge trash on exit? What mail clients are you using?
Hi!, thank you for answer.
Most of my users (about 90%) use only webmail.
if we had figure this out in the beginning, it would have been easy, but now, with +200 webmail users, have to get in and configure in every user, will be almost impossible! :(
Even a way to purge all trash of all users at one given time, done by the admin, will be enough, but just can't figure it out how to do it.
thank you
light
-
You might wanna take a look at /etc/e-smith/events/actions/purge-junkmail-folders
This is called from /etc/crond.d
To do this nicely use the template system.
-
The challenge here is that the deleted emails have not been moved to a specific folder as junkmail. The filename has just been changed so that it has a "T" for trashed in the end.
So you want to make a script that finds the "T" files that are older than Y days.
Content that is more than 30 days old within the .Trash directories made by Thunderbird can be cleaned like this (at own risk...)
find /home/e-smith/files/users/ -regex '.*/\.\(Trash\|Junk\)\(/.*\)?\/\(cur\|new\)/.*' -type f -ctime +30 -delete
Dovecot:
http://cr.yp.to/proto/maildir.html
-
The challenge here is that the deleted emails have not been moved to a specific folder as junkmail. The filename has just been changed so that it has a "T" for trashed in the end.
Then this won't do you any good:
find /home/e-smith/files/users/ -regex '.*/\.\(Trash\|Junk\)\(/.*\)?\/\(cur\|new\)/.*' -type f -ctime +30 -delete
If deleted files have a T at the end and are not in specific folders you can do something like this in a script:
#!/bin/sh
# Location of the Maildir folder(s)
MAILDIR=/home/e-smith/files/users/*/Maildir/
# Age of the files in days
RETENTION_TIME=30
# Delete them (yes) or only list them (no)
DELETE=no
find $MAILDIR -type f -name *T -ctime $RETENTION_TIME $(if [ "$DELETE" == "yes" ]; then echo " -delete"; fi)
Remark:Since you stated you are using webmail, which is backed by a MySQL database for it's data I am not sure if this will work to full satisfaction as I am not sure which data is stored in the MySQL database and what is read from the filesystem. If the state of e-mails is also stored, it might be that the interface is showing mail that might not be there after you have run the script.