diff -u -r postfix-2.3-20050724/src/cleanup/cleanup.h postfix-2.3-20050724-patch/src/cleanup/cleanup.h
--- postfix-2.3-20050724/src/cleanup/cleanup.h	2005-07-14 17:41:10.000000000 +0200
+++ postfix-2.3-20050724-patch/src/cleanup/cleanup.h	2005-07-25 20:40:25.828469426 +0200
@@ -98,6 +98,13 @@
 extern MAPS *cleanup_send_bcc_maps;
 extern MAPS *cleanup_rcpt_bcc_maps;
 
+/* chars which will cause message reject or which will be stripped from message */
+
+extern VSTRING *reject_chars;
+extern VSTRING *strip_chars;
+
+
+
  /*
   * Address canonicalization fine control.
   */
diff -u -r postfix-2.3-20050724/src/cleanup/cleanup_init.c postfix-2.3-20050724-patch/src/cleanup/cleanup_init.c
--- postfix-2.3-20050724/src/cleanup/cleanup_init.c	2005-06-15 16:38:22.000000000 +0200
+++ postfix-2.3-20050724-patch/src/cleanup/cleanup_init.c	2005-07-25 20:40:25.831469031 +0200
@@ -209,6 +209,12 @@
 MAPS   *cleanup_send_bcc_maps;
 MAPS   *cleanup_rcpt_bcc_maps;
 
+/* chars which will cause message reject or which will be stripped from message */
+
+VSTRING *reject_chars;
+VSTRING *strip_chars;
+
+
  /*
   * Address extension propagation restrictions.
   */
@@ -360,4 +366,14 @@
      */
     cleanup_ext_prop_mask =
 	ext_prop_mask(VAR_PROP_EXTENSION, var_prop_extension);
+
+    /*
+     * setup the VSTRINGs which are used to check for disallowed chars 
+     * which cause message to be rejected or which are stripped out.
+     */
+	reject_chars = vstring_alloc(10);
+	unescape(reject_chars,var_msg_reject_chars);
+	strip_chars = vstring_alloc(10);
+	unescape(strip_chars,var_msg_strip_chars);
+
 }
diff -u -r postfix-2.3-20050724/src/cleanup/cleanup_message.c postfix-2.3-20050724-patch/src/cleanup/cleanup_message.c
--- postfix-2.3-20050724/src/cleanup/cleanup_message.c	2005-07-14 17:12:10.000000000 +0200
+++ postfix-2.3-20050724-patch/src/cleanup/cleanup_message.c	2005-07-25 20:40:25.834468636 +0200
@@ -293,6 +293,7 @@
 
 #define CLEANUP_ACT_CTXT_HEADER	"header"
 #define CLEANUP_ACT_CTXT_BODY	"body"
+#define CLEANUP_ACT_CTXT_MSG	"message"
 
 /* cleanup_act - act upon a header/body match */
 
@@ -703,6 +704,36 @@
 {
     char   *myname = "cleanup_message_headerbody";
     MIME_STATE_DETAIL *detail;
+	unsigned char *cp;
+	unsigned int offset = 0;
+
+	/* if buffer contains chars from message_reject_characters
+       then reject message */
+
+	if ((state->flags & CLEANUP_FLAG_FILTER) && var_msg_reject_chars) {
+		for (cp = (char * ) buf; cp < buf + len; cp++) {
+			if (vstring_instr(reject_chars, *cp)) {
+				cleanup_act(state, CLEANUP_ACT_CTXT_MSG,
+					buf, "REJECT disallowed character", "");
+				return;
+			}
+		}
+	}
+
+	/* if buffer contains chars from message_strip_characters
+	   then strip from buffer */
+
+	if (var_msg_strip_chars) {
+		for (cp = (char *) buf; cp < buf + len; cp++) {
+			if (!vstring_instr(strip_chars, *cp)) {
+				*(cp-offset) = *cp;
+			}
+			else {
+				offset++;
+			}
+		}
+		len -= offset;
+	}
 
     /*
      * Copy text record to the output.
diff -u -r postfix-2.3-20050724/src/global/mail_params.c postfix-2.3-20050724-patch/src/global/mail_params.c
--- postfix-2.3-20050724/src/global/mail_params.c	2005-06-08 00:13:59.000000000 +0200
+++ postfix-2.3-20050724-patch/src/global/mail_params.c	2005-07-25 20:40:25.836468373 +0200
@@ -104,7 +104,8 @@
 /*	int     var_strict_encoding;
 /*	int     var_verify_neg_cache;
 /*	int	var_oldlog_compat;
-/*
+/*	char	*var_msg_reject_chars;
+/*	char	*var_msg_strip_chars;/*
 /*	void	mail_params_init()
 /*
 /*	const	char null_format_string[1];
@@ -298,6 +299,8 @@
 int     var_strict_encoding;
 int     var_verify_neg_cache;
 int     var_oldlog_compat;
+char    *var_msg_reject_chars;
+char    *var_msg_strip_chars;
 
 const char null_format_string[1] = "";
 
@@ -513,6 +516,8 @@
 	VAR_FLUSH_SERVICE, DEF_FLUSH_SERVICE, &var_flush_service, 1, 0,
 	VAR_VERIFY_SERVICE, DEF_VERIFY_SERVICE, &var_verify_service, 1, 0,
 	VAR_TRACE_SERVICE, DEF_TRACE_SERVICE, &var_trace_service, 1, 0,
+	VAR_MSG_REJECT_CHARS, DEF_MSG_REJECT_CHARS, &var_msg_reject_chars, 0, 0,
+	VAR_MSG_STRIP_CHARS, DEF_MSG_STRIP_CHARS, &var_msg_strip_chars, 0, 0,
 #ifdef USE_TLS
 	VAR_TLS_RAND_EXCH_NAME, DEF_TLS_RAND_EXCH_NAME, &var_tls_rand_exch_name, 0, 0,
 	VAR_SMTPD_TLS_CERT_FILE, DEF_SMTPD_TLS_CERT_FILE, &var_smtpd_tls_cert_file, 0, 0,
diff -u -r postfix-2.3-20050724/src/global/mail_params.h postfix-2.3-20050724-patch/src/global/mail_params.h
--- postfix-2.3-20050724/src/global/mail_params.h	2005-07-21 02:26:27.000000000 +0200
+++ postfix-2.3-20050724-patch/src/global/mail_params.h	2005-07-25 20:40:25.842467583 +0200
@@ -2362,6 +2362,18 @@
   */
 extern const char null_format_string[1];
 
+ /*
+  * chars which cause reject or which are stripped
+  */
+
+#define VAR_MSG_REJECT_CHARS	"message_reject_characters"
+#define DEF_MSG_REJECT_CHARS	""
+extern char * var_msg_reject_chars;
+
+#define VAR_MSG_STRIP_CHARS		"message_strip_characters"
+#define DEF_MSG_STRIP_CHARS		""
+extern char * var_msg_strip_chars;
+
 /* LICENSE
 /* .ad
 /* .fi
diff -u -r postfix-2.3-20050724/src/util/vstring.c postfix-2.3-20050724-patch/src/util/vstring.c
--- postfix-2.3-20050724/src/util/vstring.c	2005-07-24 01:53:49.000000000 +0200
+++ postfix-2.3-20050724-patch/src/util/vstring.c	2005-07-25 20:40:25.846467056 +0200
@@ -596,6 +596,17 @@
     return (vp);
 }
 
+/* vstring_instr - returns 1 if needle is found in vp else 0 */
+
+int vstring_instr(VSTRING *vp, char needle)
+{
+	unsigned char * cp;
+	for (cp = vp->vbuf.data; cp < vp->vbuf.ptr; cp++) {
+		if ( *cp == needle) return 1;
+	}
+	return 0;
+}
+
 #ifdef TEST
 
  /*
diff -u -r postfix-2.3-20050724/src/util/vstring.h postfix-2.3-20050724-patch/src/util/vstring.h
--- postfix-2.3-20050724/src/util/vstring.h	2005-07-16 01:52:54.000000000 +0200
+++ postfix-2.3-20050724-patch/src/util/vstring.h	2005-07-25 20:40:25.848466793 +0200
@@ -47,6 +47,7 @@
 extern VSTRING *PRINTFLIKE(2, 3) vstring_sprintf_prepend(VSTRING *, const char *, ...);
 extern char *vstring_export(VSTRING *);
 extern VSTRING *vstring_import(char *);
+extern int vstring_instr(VSTRING *vp, char needle);
 
 #define VSTRING_CTL_MAXLEN	1
 #define VSTRING_CTL_END		0

