qmail-script zum filtern von unerwünschten oder leeren Betreffzeilen

Slatibartfaß
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
#!/bin/sh
#
# Checksubj Script for QMAIL
#
#                 Dr. Erwin Hoffmann - FEHCom
#			Mail: <feh@fehcom.de>
#			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:)
#  bei PLESK (10) /var/qmail/mailnames/ihredomain.tld/.qmail-default
#
#   |/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 <berehl@eldaserv.de>)
#
#  Abfrage nach leeren Betreffzeilen eingefuegt. 12.05.11 Andreas Maas
#  Mails mit leerem Betreff werden verworfen.
#  Mails mit unerwuenschtem Wort werden gebounced.
#---------------------------------------------------------------------------
printsubj () {

  echo "Ihre E-Mail wurde abgewiesen, da der Betreff dieses unerwuenschte Wort enthaelt : $SUBJECTLINE."
  echo
  echo "Your E-Mail was rejected because it contained a Subject like: $SUBJECTLINE."
  echo "Sorry, we don't accept those E-Mails."
  }

  checksubject () {


    case $SUBJECTLINE in
 ILOVEYOU|iloveyou|empty|break|*ex|*orno*|Gay|gay|GAY|Men|men|*ctual|*izes|her|Her|*ome|*ather|*jaculation|*onth|VIAGRA|*iagra|*antastic|*rump|*ains|*ealth|adult||Adult|ADULT|*eight|*aty)
 
 	printsubj $SUBJECTLINE

	 exit $code;;
		*)
	        ;;
		  esac

		}

		  SUBJECT=`(grep "Subject: " | head -n 1 | awk -F: '{print $2}')`

# ----------------------------------------------------------------------------------------
# Filterung, ob Betreffzeile leer, Modifiziert 12.05.11 Andreas Maas

	b=${#SUBJECT}
	if [ "$b" = "1" ]; then
		SUBJECT="empty"
                code="99"
	else
		code="100"

	fi	

# ----------------------------------------------------------------------------------------

		  for SUBJECTLINE in $SUBJECT
		  do
		   checksubject $SUBJECTLINE
		  done

		   exit 0