Hi,

Here is a modified version of selectively filtering
attachments.

I've use this for days already and I'm happy with it.
But again, I consider this a crude script.
Use at your own risk #:^)


Thanks

Noel Mistula

==========================================
#!/bin/bash
#
# qmail -- checkattach
# Author: Noel G. Mistula
# Date: 28 June 1999 Version: 0.1
#
# Modified: 7 July 1999 Version: 0.3

# This is release under the GNU/GPL.
# This is a very crude program. Use at your own risk.
# This will delete incoming email with executable,
# video and other attachments. Just remove/add
# whichever filetype (e.g. EXE, AVI, COM) is required.
#
# I use this in a user's .qmail file
# by adding the line
# |/usr/local/bin/checkattach
# before the ./Maildir/
#

# Start program here. Check for _not_ allowed attachment.
# This part is the new version (ver. 0.3)
printmsg () {
 echo "The reason why your email was rejected is you sent an attachment of
filetype=$ATTYPE."
 echo "Sorry, $ATTYPE attachment can cause problems like virus, or increase
traffic load, or delete file(s) and/or among others."
}

# The CASE selection below can be broken down into each respective filetype
# to customise the error message. I only use the generalise (printmsg)
# message above.
checktype () {
 case $ATTYPE in
  EXE | COM | BAT | CMD | AVI | MOV | RAM | BMP | MPE | MPG | MP3 | MP4 |
WAV | AUD)
   printmsg $ATTYPE
   exit 100;;
  *)
   ;;
 esac
}

# The "filename=" below can be replace with "file=" because
# sometimes other MUA's doesn't use "filename=".
ATTACHTYPE=`grep "filename=" - | gawk '{split($NF, results, ".");
r=toupper(results[2]); print r}' | cut -c -3`
for ATTYPE in $ATTACHTYPE
do
 checktype $ATTYPE
done
# End of ver. 0.3

exit 0
================================================

Reply via email to