Re: Removing SpamAssassin wrappers from an email item

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Leslie!

Anno domini 2021 Fri, 1 Oct 20:06:07 -0500
 J Leslie Turriff scripsit:
> 	When SpamAssassin misclassifies a piece of mail as spam, it wraps a
>  bunch of stuff around the original message.  When I use the Classify as NOT
> spam filter it changes the classification, but leaves the wrapper intact.
> 	Does anyone out there know how to write a filter stage to strip that
> junk off again?  (See attachments)
> 
> Leslie
> --
>    Operating System: Linux
>        Distribution: openSUSE Leap 15.3 x86_64
> Desktop Environment: Trinity
>                  Qt: 3.5.0
>                 TDE: R14.0.10
>          tde-config: 1.0
> 

In kmail go "Settings/Filters" --> "Classify as HAM" and add a filteraction "Run through program" (freely translated from german GUI) so the first action is "Mark as HAM" and the second runs the header saitizer program. I have attached a filter from my system that I use to that decrypts/sanitises mail headers for you as a starting point. 

Nik

-- 
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
#!/bin/bash
#
# (c) 31.7.2018, Dr. Nikolaus Klepp - dr.klepp@xxxxxx / office@xxxxxxxxx
#

case "$1" in
	-?|-h|--help)
		echo "Decrypts and sanitizes email comming from stdin."
		echo "usage: $(basename $0) FILENAME"
		exit 1
	;;
esac


INCOMMING=$(mktemp)
TMP=$(mktemp)

cat > $INCOMMING


cat "$INCOMMING" | awk '
BEGIN {
	header=1
	clear=0
	binary=0
	encrypted=0
	subject=""
}

/^[^ ].*/	{
	if (header==1) {
		clear=0
	}
}

/^[sS][uU][bB][jJ][eE][cC][tT]:/ {
	if (header==1) {
		subject=$0
		clear=1
	}
}


# Alle unerwünschten Headereinträge
/^(X-UI-Filterresults:|X-GMX-Antivirus:|X-GMX-Antispam:|X-CNFS-Analysis:|DKIM-Signature:|[xX]-[mM][sS]-|x-exchange-|x-forefront-|x-microsoft-|spamdiagnostic)/ {
	if (header==1) {
		clear=1
	}
}

		

# Ende des Headers
/^$/ { 
	if (header) {
		header=0
		clear=0
		if (encrypted) {
			print subject " *DECRYPTED*"
			if (0!=system("gpg2 -d \"'$INCOMMING'\" 2>/dev/null")) {
				system("rm \"'$TMP'\"")
			}
			exit 1
		} else {
			print subject
		}
	}
}

/^Content-Type: multipart\/encrypted;$/	{
	if (header) {
		clear=1
		encrypted=1
	}
}



{	
	if (header==1) {
		if (clear==0) {
			print $0
		}
	} else {
		print $0
	}
}

' > $TMP



if [ -f $TMP ]; then
	mv $TMP $INCOMMING
fi

cat $INCOMMING
rm $INCOMMING

____________________________________________________
tde-users mailing list -- users@xxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxx
Web mail archive available at https://mail.trinitydesktop.org/mailman3/hyperkitty/list/users@xxxxxxxxxxxxxxxxxx

[Index of Archives]     [Trinity Devel]     [KDE]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]     [Trinity Desktop Environment]

  Powered by Linux