Obsolete Releases > SME 8.x Contribs
a bash routine for deleting email placed in the trash folder of all users
purvis:
A bash routine for deleting email placed in the trash folder of all users
The email files inside the .trash folder of all users with dates older than 180 days from the servers date will be deleted.
I wrote this bash routine to reduce the number of email files that will be scanned for viruses using another routine written by myself and your can find that at the below link.
http://forums.contribs.org/index.php/topic,49670.0.html
USE AT YOUR OWN RISK.
--- Code: ---#!/bin/bash
find /home/e-smith/files/users/*/Maildir/.trash -name "1*.P*.$HOSTNAME*" -mtime +180 -exec rm {} \;
exit 0
--- End code ---
If you only want to list all the email files in only the .trash folder of all users , you can list them with this bash code
--- Code: ---#!/bin/bash
find /home/e-smith/files/users/*/Maildir/.trash -name "1*.*.$HOSTNAME*"
#or
#find /home/e-smith/files/users/*/Maildir/.trash -name "1*.*.$HOSTNAME*" -exec ls -l {} \;
exit 0
--- End code ---
If you want to list all the email files in of all users , you can list them with this bash code
--- Code: ---#!/bin/bash
find /home/e-smith/files/users/*/Maildir/* -name "1*.*.$HOSTNAME*" -exec ls -l {} \;
#or
#find /home/e-smith/files/users/*/Maildir/* -name "1*.*.$HOSTNAME*"
exit 0
--- End code ---
With the bash code immediately above. I found out we where receiving email to accounts that I thought were set to not receive any email from the internet but we where.
That was stopped with the below code
--- Code: ---db accounts setprop usernamehere Visible internal
signal-event email-update
--- End code ---
larieu:
I have seen over the time that the option
--- Code: ----exec rm {} \;
--- End code ---
will have some issues
to avoid them I have something like
--- Code: ----type f -delete
--- End code ---
which worked fine ever since I have wrote it
mmccarn:
Would it be useful to adapt the 'action' script that deletes old emails from the .junkmail folder based on a db entry?
/etc/e-smith/events/actions/purge-junkmail-folders
That script is run every evening at 11:25pm by cron based on this cron script:
/etc/cron.d/purge_junkmail
purvis:
Yes on the junk mail script if a server manager panel option can be made for the number of days.
Set number of days to default at 7 years.
I don't know how to do that. Sorry
larieu:
mmccarn
It will be nice to have something automated to delete old "deleted but not purged" emails for the whole server, too
But until now I wasn't be able to find a reliable way to differentiate them from "non ready to be purged" emails, mostly because this emails are mixed into the same folders with normal ones.
Actually the trouble is for accounts used only form mobile phones
The mails came into inbox from where are deleted (it appears as deleted but not purged) , then copied into "Deleted Items" from where some users also delete them and there all of them remains also marked as deleted but not purged
imagine someone with a quota of 500M
The person receive 250M he/she delete them (it remain into inbox and are copied to "deleted Items" by the mobile phone app) that means 500M is reached and then he/she delete them from deleted items (in the fortunate case that the user mobile is set to see more than 30 days)
Apparently the user has no email on his account, But in reality he/she has 500M full quota used
On mobile phones (Android/iPhone/RIM(BB) ) I wasn't able to find a purge option
IF the user login into webmail and just push purge on the targeted folders - everything is ok
But this is not "easy" for them as they use only the mobile phone
Navigation
[0] Message Index
[#] Next page
Go to full version