Liu Shuai wrote:
> I want to set up a system wide cron job that deletes old (2 weeks
> maybe) tagged spam from each user's spam folder, but I am not sure
> how.

A bit of Perl and a lot of swearing at the problems encountered parsing
mbox files.  <g>

> Does anybody here has a script that does similar job that I can use
> as a reference? If not, can some one give me some direction? I assume
> I need a parser that will parse each user's spam folder so that I can
> retrieve the date of each message?

Read on.  I've actually developed a pair of scripts for handling this
processing systemwide on the filter server I admin.

I've posted these scripts to http://www.deepnet.cx/~kdeugau/spamtools:

  autoexpirespam.pl:  Expire spam from users approaching an arbitrary
disk space limit, and empty their trash folders as well.  Accepts two
parameters- 1) number of time periods to retain for accounts that get
trimmed, and 2) the units to use (should understand days or months). 
Default is 30 days.

  expirespam.pl:  Single-account forced-expiry version of above. 
Requires a username as 1st parameter;  second and third are repectively
the same as first and second above.  Default is the same, 30 days.

  countspam.pl:  Produces a (very) simple summary of spams-per-day
currently in the spambox.  Doesn't quite sort-by-date correctly.

  space_warn.pl:  Send warnings to users approaching their quota.  Note
that it does NOT "send" email;  it simply writes an mbox-friendly
message on to the end of the user's inbox.  This eliminates problems
with contacting overquota accounts.   >:)

Note that the first three assume that the "From " line was generated by
either the local MTA or the local delivery agent, and can therefore be
trusted to contain an accurate date.  All should even handle email
addresses with whitespace (ugh) in them.

I have entries in /etc/crontab like so:
30 1 * * * root /root/custom-spam
30 2 * * * root /root/autoexpirespam.pl 28
45 3 * * * root /root/space_warn.pl

custom-spam is a shell script which calls expirespam.pl repeatedly on
accounts that get too much spam to fit in the 20M quota;  I've fancied
it up a little so that the cron report root gets is a little clearer.

The calls are in that order to minimize processing.

WorksForMe(TM), YMMV, etc, etc.  I've yet to actually *lose* email with
these scripts in almost a year and a half, although I've occasionally
been surprised by a result due to the horrible things spammers have
managed to do with the SMTP envelope sender.

You'll probably have to modify things for your system;  quite a few
things there are hard-coded.  :/

-kgd
-- 
"Sendmail administration is not black magic.  There are legitimate
technical reasons why it requires the sacrificing of a live chicken."
   - Unknown


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to