diff -urw sendmail-8.13.6-orig/cf/m4/proto.m4 sendmail-8.13.6-badrcpt/cf/m4/proto.m4
--- sendmail-8.13.6-orig/cf/m4/proto.m4	2005-08-24 14:07:23.000000000 -0400
+++ sendmail-8.13.6-badrcpt/cf/m4/proto.m4	2006-03-22 22:45:27.000000000 -0500
@@ -578,6 +578,19 @@
 # once the threshold number of recipients have been rejected
 _OPTION(BadRcptThrottle, `confBAD_RCPT_THROTTLE', `0')
 
+ifdef(`_FFR_BADRCPT_SHUTDOWN', `dnl
+# number of bad recipients before connection is evaluated for
+# shutdown with 421 code. Zero disables. Numbers less than 5 not
+# recommended.
+_OPTION(BadRcptShutdown, `confBAD_RCPT_SHUTDOWN', `0')
+# Percentage of bad recipients of total before shutdown is 
+# allowed. 81 is a good number, only dropping connection if 
+# 2 out of 10 rcpts or less are good.
+# If 100, the connection will never be shut down onon good recipients.
+# If 0 the connection will be shut down as soon as BadRcptShutdown
+# bad rcpts are reached.
+_OPTION(BadRcptShutdownGood, `confBAD_RCPT_SHUTDOWN_GOOD', `100')')
+
 # shall we get local names from our installed interfaces?
 _OPTION(DontProbeInterfaces, `confDONT_PROBE_INTERFACES', `False')
 
diff -urw sendmail-8.13.6-orig/sendmail/conf.c sendmail-8.13.6-badrcpt/sendmail/conf.c
--- sendmail-8.13.6-orig/sendmail/conf.c	2006-02-23 21:21:53.000000000 -0500
+++ sendmail-8.13.6-badrcpt/sendmail/conf.c	2006-03-22 22:45:27.000000000 -0500
@@ -6279,6 +6279,10 @@
 	/* Exponential queue delay; disabled in 8.13 since it isn't used. */
 	"_FFR_QUEUEDELAY",
 #endif /* _FFR_QUEUEDELAY */
+#if _FFR_BADRCPT_SHUTDOWN
+	/* 421 for BadRcptShutdown and BadRcptShutdownGood percentage */
+	"_FFR_BADRCPT_SHUTDOWN",
+#endif /* _FFR_BADRCPT_SHUTDOWN */
 #if _FFR_QUEUE_GROUP_SORTORDER
 	/* Allow QueueSortOrder per queue group. */
 /* XXX: Still need to actually use qgrp->qg_sortorder */
diff -urw sendmail-8.13.6-orig/sendmail/readcf.c sendmail-8.13.6-badrcpt/sendmail/readcf.c
--- sendmail-8.13.6-orig/sendmail/readcf.c	2006-03-02 14:17:09.000000000 -0500
+++ sendmail-8.13.6-badrcpt/sendmail/readcf.c	2006-03-22 22:49:37.000000000 -0500
@@ -2187,6 +2187,12 @@
 # define O_CRLPATH	0xd7
 	{ "CRLPath",		O_CRLPATH,	OI_NONE	},
 #endif /* _FFR_CRLPATH */
+#if _FFR_BADRCPT_SHUTDOWN
+# define O_RCPTSHUTD	0xe9
+	{ "BadRcptShutdown",		O_RCPTSHUTD,	OI_SAFE },
+# define O_RCPTSHUTDG	0xea
+	{ "BadRcptShutdownGood",	O_RCPTSHUTDG,	OI_SAFE	},
+#endif /* _FFR_BADRCPT_SHUTDOWN */
 #if _FFR_HELONAME
 # define O_HELONAME 0xd8
 	{ "HeloName",   O_HELONAME,     OI_NONE },
@@ -3274,6 +3280,16 @@
 	  case O_RCPTTHROT:
 		BadRcptThrottle = atoi(val);
 		break;
+#if _FFR_BADRCPT_SHUTDOWN
+		
+	  case O_RCPTSHUTD:
+		BadRcptShutdown = atoi(val);
+		break;
+		
+	  case O_RCPTSHUTDG:
+		BadRcptShutdownGood = atoi(val);
+		break;
+#endif /* _FFR_BADRCPT_SHUTDOWN */
 
 	  case O_DEADLETTER:
 		CANONIFY(val);
diff -urw sendmail-8.13.6-orig/sendmail/sendmail.h sendmail-8.13.6-badrcpt/sendmail/sendmail.h
--- sendmail-8.13.6-orig/sendmail/sendmail.h	2006-02-27 12:49:09.000000000 -0500
+++ sendmail-8.13.6-badrcpt/sendmail/sendmail.h	2006-03-22 22:45:27.000000000 -0500
@@ -2197,6 +2197,10 @@
 EXTERN char	OpMode;		/* operation mode, see below */
 EXTERN char	SpaceSub;	/* substitution for <lwsp> */
 EXTERN int	BadRcptThrottle; /* Throttle rejected RCPTs per SMTP message */
+#if _FFR_BADRCPT_SHUTDOWN
+EXTERN int	BadRcptShutdown; /* Shutdown connection for rejected RCPTs */
+EXTERN int	BadRcptShutdownGood; /* above even when there are good RCPTs */
+#endif /* _FFR_BADRCPT_SHUTDOWN */
 EXTERN int	CheckpointInterval;	/* queue file checkpoint interval */
 EXTERN int	ConfigLevel;	/* config file level */
 EXTERN int	ConnRateThrottle;	/* throttle for SMTP connection rate */
diff -urw sendmail-8.13.6-orig/sendmail/srvrsmtp.c sendmail-8.13.6-badrcpt/sendmail/srvrsmtp.c
--- sendmail-8.13.6-orig/sendmail/srvrsmtp.c	2006-02-27 19:42:13.000000000 -0500
+++ sendmail-8.13.6-badrcpt/sendmail/srvrsmtp.c	2006-03-22 22:45:27.000000000 -0500
@@ -2418,6 +2418,41 @@
 
 		  case CMDRCPT:		/* rcpt -- designate recipient */
 			DELAY_CONN("RCPT");
+#if _FFR_BADRCPT_SHUTDOWN 
+			if (BadRcptShutdown > 0 &&
+				n_badrcpts >= BadRcptShutdown)
+			{
+				bool result_flag = false;
+				
+				if (!BadRcptShutdownGood || !smtp.sm_nrcpts)
+					result_flag = true;
+					
+				if (!result_flag)
+				{
+					float f = n_badrcpts;
+					float g = smtp.sm_nrcpts + n_badrcpts;
+					float h = f/g;
+
+					h *= 100.00;
+					if (h >= BadRcptShutdownGood) 
+						result_flag = true;
+				}
+				
+				if (result_flag)
+				{
+					if (LogLevel > 5)
+						sm_syslog(LOG_INFO, e->e_id,
+							  "%s: Possible SMTP RCPT flood, shutting down connection.",
+							  CurSmtpClient);
+					message("421 4.7.0 %s Too many bad recipients; closing connection",
+					MyHostName);
+
+					/* arrange to ignore any current send list */
+					e->e_sendqueue = NULL;
+					goto doquit;
+				}
+			}
+#endif /* _FFR_BADRCPT_SHUTDOWN */
 			if (BadRcptThrottle > 0 &&
 			    n_badrcpts >= BadRcptThrottle)
 			{
