[Mimedefang] code 421 and filter_sender

Mike Batchelor mikebat at gmail.com
Tue Dec 6 19:29:00 EST 2005

I have this code in filter_recipient, and it works as expected. 
Sendmail issues the 421 error and drops the connection as soon as a
recipient is given, if the sender matched:

sub filter_recipient {
   if ($sender =~ /^<admin\@fbi\.gov>?$/i) {
      return('TEMPFAIL', "$sender is wormsign.", '421', '4.2.1');

mail from:<admin at fbi.gov>
250 2.1.0 <admin at fbi.gov>... Sender ok
rcpt to:<mike at texample.com>
421 4.2.1 <admin at fbi.gov> is wormsign.
Connection closed by foreign host.

This is just what I want.  Sober M681 will try a different sender if
the first one is rejected and the socket is kept open, and will try as
 many recipients as it can, all of which are rejected and fill my logs
with repeated reject messages. So 550's and such do nothing but keep
the worm on the socket longer.  The 421 code is the only way to get
sendmail to peremptorily resert the socket.

But if I put this same code in filter_sender, to reject the worms
sooner, it does not drop the connection.  It issues the 421 error, but
keeps the connection open.  Why is that?  It's doing the job in
filter_recipient (the worm does not retry a dropped connection), but
filter_sender is where it should logically be placed.  I wouldn't call
this a bug or anythng, I am just curious why it behaves like this. 
Sendmail 8.13.x will reset the connection when a Milter returns 421,
just like it would if it issued 421 from its own code.  But why not
from within filter_sender?

More information about the MIMEDefang mailing list