#!/bin/sh # # Checksubj Script for QMAIL # # Dr. Erwin Hoffmann - FEHCom # Mail: # Web: http://www.fehcom.de # Date: 2000-09-26 # Version: 0.3 # # Installation: # ------------- # # 1. Install the script in /var/qmail/bin (together with the QMAIL binaries) # 2. chmod 755 checkmail; chown root.qmail checkmail # # Usage: # ------ # # Include a call to this script into # (1) your user's .qmail files and - if applicable - into # (2) /var/qmail/alias/.qmail-default (first line:) # # |/var/qmail/bin/checkmail # ~/Maildir/ (or ~/mbox) # # Be sure to have a postmaster account defined to treat double-bounces unfiltered. # # Filtering: # ---------- # # - Modify the subject text fields (samples) in "checksubj" to your needs, # eg. add "|*insurance*". # - The script evaluates the string case sensitive! # - Avoid white spaces (blanks) between the filtering string and the "|"! # - It allows wildcards, be careful! # # Results: # -------- # # 1. The sender becomes the E-Mail bounced. # 2. You can watch the results (and test the script) viewing your Maillog. # # Dependencies: # ------------- # # This version depends on your "awk" routine. # If necessary change it to "nawk" or "gawk" and/or install them. # # Original Version: # ----------------- # # I took this script form Noel. G. Mistula's checkattach and changed it to # the checksubj control. # # History: # -------- # # Version 0.2 - first release # Version 0.3 - only first "Subject:" Line in E-Mail is considered # (suggested by Bernd Ehlert ) # #--------------------------------------------------------------------------- printsubj () { echo "Your E-Mail was rejected is because it contained a Subject like: $SUBJECTLINE." echo "Sorry, we don't accept those E-Mails." } checksubject () { case $SUBJECTLINE in ILOVEYOU|iloveyou|Sex|Porno*) printsubj $SUBJECTLINE exit 100;; *) ;; esac } SUBJECT=`(grep "Subject: " | head -n 1 | awk -F: '{print $2}')` for SUBJECTLINE in $SUBJECT do checksubject $SUBJECTLINE done exit 0