--- mimedefang.pl	Fri Aug 15 20:03:41 2008
+++ mimedefang.pl.data	Mon Oct 20 17:41:08 2008
@@ -5517,10 +5517,32 @@
     if (!open(RESULTS, ">RESULTS")) {
 	fatal("$MsgID: Could not open RESULTS file: $!");
 	return -1;
     }
 
+    # Call pre-pre-scan filter if defined
+    if (defined(&filter_before)) {
+	push_status_tag("In filter_before");
+	filter_before();
+	pop_status_tag();
+	# Have we allreeady decided to reject or discard?
+	if (message_rejected()) {
+	    md_syslog('debug', "$MsgID: filter_before rejected or discarded.");
+	    signal_unchanged();
+    	    signal_complete();
+    	    return 0;
+    	}
+	# If stream_by_domain tells us to discard, do so...
+	if ($TerminateAndDiscard) {
+	    write_result_line("D", "");
+	    signal_unchanged();
+	    md_syslog('debug', "$MsgID: filter_before set TerminateAndDiscard flag.");
+	    signal_complete();
+	    return 0;
+	}
+    }
+
     my $entity;
     my $parser;
     if (defined(&filter_create_parser)) {
 	$parser = filter_create_parser();
 	if (!defined($parser) ||
