HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=29)
-   -   Rule to delete old email and auto import into blacklist (http://www.howtoforge.com/forums/showthread.php?t=60604)

0riole 18th February 2013 03:57

Rule to delete old email and auto import into blacklist
 
Hi All,

I'm looking for a way to set a rule in ISPConfig 3 or Postfix to delete old emails from the server, say any email older then say 14 days. Also would like one to collect email addresses from Junk folders and add them to blacklists. BTW I'm using CentOS 6.3

TIA
Chris

till 18th February 2013 09:33

Neither postfix nor ispconfig has such a function builtin.

You will have to write script that goes trogh all email folders in /var/vmail to remove the olr mails and forward spam mails to spamassassin, e.g. as a cronjob.

Seee e.g. here for a script that removes old mails from maildir:

http://www.ducea.com/2006/11/25/clea...ete-old-mails/

Turbanator 19th February 2013 23:36

Here is a simple script I use. I think I may have pulled it form here years ago.
Code:


#!/bin/sh
# Time to wait before removing mails from the Junk folder (Default: 7 days) Set 0 to turn off.
junk_max_hours=$((24*7))
# Time to wait before removing mails from the Trash folder (Default: 30 days) Set 0 to turn off.
trash_max_hours=$((24*30))
for domain in /var/vmail/*
do
  if [ -d "$domain" ]
  then
    for user in $domain/*
    do
      if [ "$junk_max_hours" -gt "0" ]
      then
        if [ -d "$user/.Junk" ]
        then
          tmpreaper -m $junk_max_hours $user/.Junk/{cur,new}
        fi
      fi
      if [ "$trash_max_hours" -gt "0" ]
      then
        if [ -d "$user/.Trash" ]
        then
          tmpreaper -m $trash_max_hours $user/.Trash/{cur,new}
        fi
      fi
    done
  fi
done

For spamassassin learning

Code:

#!/bin/sh
/usr/bin/sa-learn --spam /var/vmail/(domain)/.Junk/*/*



All times are GMT +2. The time now is 02:41.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.