Gary wrote:

> I'm sure you have already solved the problem, but if you would like,
> here is a script that appears to work for me. I'm not a shell
> programmer, and I'm sure it shows. Use at your own risk.

> #!/bin/bash
> # feeds local quarantined mail to amavisd-release for a given domain.
> # please insure the same mail does not get quarantined again.
> # assumes spam-u02EEf0XKsV5.gz style file names.

> quarantine_dir=/var/lib/amavis/virusmails/ # need the trailing slash
> domain=example.com
> sent_log=/root/sent.log

> dir_length=${#quarantine_dir}
> #echo $dir_length

> for f in `find $quarantine_dir -type f`; do
> #sleep 1  # slow it down if desired
> filename=$f
> #echo $filename_length

> if echo $filename | grep 'spam' # or banned
> then
>   string=`zgrep 'X-Envelope-To: ' $f` 
>   if echo $string | grep $domain
>   then
>     filename_length=${#filename}
>     short_file_name=`echo $filename | cut -c $dir_length-$filename_length`
>     #trim the leading slash:
>     short_file_name=${short_file_name:1:20} # change 20 to 22 for banned
>     #echo $short_file_name
>     echo $short_file_name | amavisd-release -
>     echo $short_file_name >> $sent_log
>   fi
> fi
> done
> exit

corrections:

string=`zgrep -m 1 'X-Envelope-To: ' $f`
prevent reading the entire file once this text is found.

#sleep 1  # slow it down if desired
should be moved into the inner if statement.

Of course the biggest flaw is that the recipient's domain may be
listed not on the X-Envelope-To: line, but a line below it. Also, as
mentioned, recipients in other domains would also get a copy.

One should also consider moving the files to another directory once they
are sent so you could stop and restart if needed.

Gary V


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to