Justin C. Le Grice wrote:
Barney Desmond wrote:
2009/8/24 Justin C. Le Grice <mailingli...@legrice.co.nz>:
I am new to the world of postfix. I have managed to successfully implement
Postfix etc using workaround.org's excellent guide.
My current item on the wish list is how to sweep items from the users Spam
folders after a defined number of days.
This is the Postfix list, Postfix is only an MTA. It does not deal
with serving mailboxes. That said...
I have located this script from http://moze.koze.net/?p=161
<snip>
My guess as to what this does is the following
You really don't want to be guessing here - it could wipe out your
system for all you know. The script should have documentation. If not,
you need to learn up on shell scripting.
1. Find any occurances of .Spam directory under /var/vmail
2. for each .Spam directory found, locate and delete any items found in new
and cur directories over 365 days old.
Am I correct here?
That sounds about right.
If so what do I do with this script
You run it, however you want.
and how do I use it in a weekly cron
job?
Put it in a weekly cronjob.
I don't mean to come off as rude, but these aren't really good
questions, relevant or otherwise.
Gee Barney that was really friendly, NOT!
If you had read what I was asking you should have worked out that I am
looking for a solution for a particular issue I wish to resolve. I was
trying to understand how this one worked. I have not implemented it
because I was not 100% how it worked, nor how to tweak it to suit my needs.
As I also said I am new to Postfix, and also Linux so am gingerly
feeling my way through setting up this mail server. I posed my question
here because I was sure the friendly (now I'm not so sure) folks here
would have come across this particular problem and would have a solution.
Cheers
Ideally, the script would find all subdirectories of /var/vmail
containing the string "Maildir/.Spam/" and then delete the messages in
those directories which are older than 365 days. But it's buggy.
First of all, if you copy-and-pasted the code exactly, the apostrophes
around the sed command most likely did not come through, nor did the
quotes around grep's argument. That page uses HTML entities for angled
quotes, rather than plain ASCII ones. Fortunately, sed and grep will
crash, rather than, say, passing all of your files to the "rm" command.
Second, it's grepping for a path containing "Maildir/.Spam/" and then
trying to delete within that path. Try running "find" somewhere on your
machine. Do the directories end with slashes? Not here, they don't. So,
the script doesn't even empty the .Spam folder. It /almost/ empties the
subdirectories of the .Spam folder, but the author is missing two front
slashes in his find commands. For example, given the following directory
structure,
$ ls /var/vmail/example.com/user/Maildir/.Spam/
drwxr-xr-x 2 mjo mjo 4.0K 2009-08-25 00:32 old-spam
-rw-r--r-- 1 mjo mjo 0 2009-08-25 00:32 test.msg
The script will try to execute the (truncated) commands:
find /var/vmail/example.com/user/Maildir/.Spam/old-spamnew/ ...
find /var/vmail/example.com/user/Maildir/.Spam/old-spamcur/ ...
which are clearly incorrect.
Third, if you followed the workaround.org tutorial, you don't even have
.Spam folders, you have .spam folders, and the case of the 's' matters.
You don't want to run a script like this (as root!) without knowing what
it does. One misplaced front slash or period could cause you to erase
the entire filesystem. You can cause similar damage with cron if you
just follow some stranger's advice without making sure you understand
what you're doing.
Finally, the workaround.org tutorial involves Dovecot, which already has
a plugin to do exactly what you want:
http://wiki.dovecot.org/Plugins/Expire
The setup is a little painful, but it's The Right Way To Do It. Help can
be found on the Dovecot mailing list. And please, forget everything you
read on that script's website.