View Single Post
  #8  
Old 7th January 2008, 11:01
MTvermoes MTvermoes is offline
Junior Member
 
Join Date: Dec 2007
Posts: 17
Thanks: 1
Thanked 10 Times in 5 Posts
Default Auto Remove Junk Older than 14 Days

I have implemented the move spam to Junk, and ran into a problem :
Users getting their mail with pop3 don't see all the spam in .Junk Folder.
The size of the junk folder will soon exeed the users disk quota.
So i found a little script on the net, and modified it a bit for use with ISPConfig.
It will remove Messages older than 14 days from users .Junk folder.
I run it daily via cron.

cat /etc/cron.daily/purge.junk
Code:
#!/bin/sh

HOURS=$((2 * 24 * 7))

for domain in /var/www/*
do
        if [ -d "$domain"/user ]
                then
                        cd $domain/user
                        for user in *
                        do
                                if [ -d "$user/Maildir/.Junk" ]
                                then
                                        tmpwatch -m $HOURS $user/Maildir/.Junk/{cur,new}
                                fi
                        done
                        cd /var/www
        fi
done
Edit(11 Jan 2008):

You might want to add :
/etc/init.d/dovecot restart
to the script, to make dovecot rebuild message indexes.



/Mark

Last edited by MTvermoes; 11th January 2008 at 22:55.
Reply With Quote